CentOS 7 Common PostgreSQL commands

Source: Internet
Author: User
Tags postgresql postgresql commands table name centos

Logged in user

After PostgreSQL is installed on CentOS 7, a postgres user is created by default. To use PostgreSQL, we need to switch to that user first:

$ sudo-i-U postgres

Then enter:

$ psql

You can enter the PostgreSQL command line. The command-line prompt at this time no longer displays $, but postgres=#.

Here, you can execute various SQL statements.

Exit PostgreSQL command Line

postgres=# \q

View all databases

postgres=# \l

Connecting to a database

postgres=# \c Test

View Table

After you connect to the database, you can view all the data tables under the database:

postgres=# \d

\d lists all of the data tables, including the PostgreSQL fields that are automatically created by the table. If you only want to view the user-created

postgres=# \dt

If you want to view the structure of a single datasheet, specify the table name after the command:

postgres=# \d Test

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.