Оглавление:
Карта сайта:
Оглавление:
Карта сайта:
Это старая версия документа!
If this PostgreSQL Tutorial saves you hours of work, please whitelist it in your ad blocker рџ and
Donate Now
to help us вќ¤пёЏ pay for the web hosting fee and CDN to keep the website running.
Summary: in this tutorial, you will learn how to show tables in PostgreSQL using psql tool and pg_catalog schema.
If you are coming from MySQL, you may want to use the popular SHOW TABLES statement that displays all tables in a specific database.
PostgreSQL does not support the SHOW TABLES statement directly but provides you with an alternative.
First, connect to PostgreSQL using psql tool.
$ psql -U postgres -W
The -U flag stands for the user and -W option requires you to provide the password. In this command, you use the postgres user to log in to the PostgreSQL database server.
Secodn, enter the password for the user postgres and press the Enter keywboard:
Password for user postgres: postgres=#
Third, switch to a database e.g.., dvdrental:
postgres=# \c dvdrental You are now connected to database "dvdrental" as user "postgres".
Note that you can connect to a specific database when you log in to the PostgreSQL database server:
$ psql -U postgres -d dvdrental
In this command, -d flag means database. In this command, you connect to the dvdrental datbase using the postgres user.
Third, use the \dt command from the PostgreSQL command prompt to show tables in the dvdrental database:
'postgres=# \dt
Code language: PHP (php) Output:
To get more information on tables, you can use the \dt+ command. It will add the size and description columns:
postgres=# \dt+
Another way to show tables in PostgreSQL is to use the SELECT statement to query data from the PostgreSQL catalog as follows:
SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';


In this query, we used a condition in the WHERE clause to filter system tables. If you omit the WHERE clause, you will get many tables including the system tables.