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