Skip to content
Middle+4 views

How do you find the relevant schema in PostgreSQL if a table cannot be found?

Practice

AI answer

First check which schemas contain the table and which schemas are available:

\dn                         -- list schemas in psql
\dt schema_name.*           -- tables in a specific schema
SHOW search_path;           -- schemas in which PostgreSQL searches for objects

You can also query the catalog:

SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_name = 'table_name';

Refer to the table by specifying its schema, for example, schema_name.table_name. If the required schema does not appear, check your access permissions and that you are connected to the correct database.