PostgreSQL - Show Tables [How to]



In this article you are going to see how simple it is to show all tables from PostgreSQL.

1.Using psql


In this article we will go over 3 ways to list tables from a PostgreSQL database:

1.List tables from a specific database

To list all available databases from PostgreSQL, execute the next command:

\l

Then, select the database:

 \c database_name

To list all the tables execute:

 \dt

2.List tables from all schemas

To show tables from all available schemas, execute the next command:

\dt *.*

3.List tables from a specific schema

To show only tables from a specific schema, execute:

\dt schema_name.*

2.Using SQL Query

To show all tables:

SELECT * FROM pg_catalog.pg_tables;

To show only tables from a specific schema, use WHERE function as it follows:

SELECT * FROM pg_catalog.pg_tables WHERE schemaname='schema_name'

Replace ‘schema_name’ with the name of the schema you want.

If you want to learn more essential commands for PostgreSQL, check out our cheat sheet

3.Using DbSchema

In DbSchema you don’t have to run any query to see the full list of your PostgreSQL database. The tables are shown in the left menu. From there, you can drag them to the layout to edit or browse.

dbschema show tables