How do I postgres list tables to view all tables in a database?

What is the equivalent command in PostgreSQL to MySQL’s SHOW TABLES?

How can I postgres list tables in a database to see all available tables?

When I started with PostgreSQL, I wanted to postgres list tables just like MySQL’s SHOW TABLES. The closest way is to connect to your database using psql and run:

\dt

This shows all tables in your current schema. If you want to see tables in other schemas, you can use \dt schema_name.*.

It’s simple and handy once you get used to psql commands.

I prefer using SQL queries to postgres list tables in a database. You can run this query:

SELECT tablename FROM pg_tables WHERE schemaname = 'public';

This lists all tables in the public schema, which is the default.

It’s a good alternative if you aren’t inside psql or want to script the listing in your apps.

For a quick way to postgres list tables, I always jump into the psql CLI and use the meta-command:

\dt

It gives a nicely formatted list of all tables.

If you need more detailed info or want to filter by schema, you can customize the command like \dt schema_name.*.

This is equivalent to MySQL’s SHOW TABLES but fits PostgreSQL’s style.