Basic use of PostgreSQL

Source: Internet
Author: User
Tags postgresql psql

Windows under
Service check
Home to see if the service is running

Find PostgreSQL Services

Service is running
Execute command

    1. Command line Management
      Open cmd command line

      Connect Database command
      Access PostgreSQL database: PSQL-H IP address-P Port-U database name
      An error may occur:

      In this case, the environment variable configuration of PostgreSQL needs to be done
      Locate the Bin folder in the installation directory of the C drive

      Setting environment variables
    2. Interface settings
      Right click on the "My Computer" button properties, pop-up properties, and then click Advanced Settings Pop-up advanced Settings screen

      Click on "Environment variables" on "System settings" to eject environment variable Settings button

      Check "path" and click "Edit"

      Click New to save

    3. Command settings
      Enter set path

      You can see the current variable value of path
      Input set path=%path%; C:\PostgreSQL\pg96\bin: You can append our path to the variable

Note that paths do not have spaces, and paths with spaces are not recognized
Execute the psql--help command again after the environment variable is modified

Indicates that the environment variable is set successfully
Access PostgreSQL database: PSQL-H IP address-P Port-U database name
Psql–h localhost–p 5432–u Postgres
localhost indicates a local
5432 is the default port number for PostgreSQL
Postgres is the default user for PostgreSQL

This screen appears to indicate a successful connection

    1. Enumerating databases
      \l Command

      All database information is listed
    2. Select Database
      \c Database name

      Switch to the test database, note the case-sensitive

      Querying data from the database
      Select * from User;

      Notice the semicolon in the back '; '

Backing Up the database
Pg_dump–h Server –p port number –U user name –d dbname–f SQL file path
Example
Pg_dump-h localhost-p 5432-u postgres-d test-f f:\Test.sql

After execution, view the Test.sql file under the F-drive

Basic use of PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.