lassence.net

List all tables from a PostgreSQL database

--- archive: codebook, 2020–2023 topic: SQL ---

If you have many schemas in your database, it can be tedious to search for a specific table across all schemas.

Below is a query to get a list of all tables names, along with their schema names. It works at least for PostgreSQL and Redshift.

SELECT table_schema, table_name
FROM information_schema.tables
ORDER BY 1,2
Subscribed, thanks. Your address is only used for this newsletter.