ERROR: relation 'table_name' does not exist
ERROR: relation 'table_name' does not exist
DodaTech
2 min read
The PostgreSQL error “ERROR: relation ’table_name’ does not exist” means the database could not find a table, view, or other relation with the specified name in the current search path.
What It Means
PostgreSQL uses a schema search path (search_path) to resolve unqualified table names. When you reference table_name without a schema prefix, PostgreSQL checks each schema in search_path in order. If no matching relation is found in any of those schemas, it returns this error.
Why It Happens
- The table does not exist in any schema accessible by the current user.
- The table exists in a schema that is not in your
search_path, e.g.,schema_name.table_name. - PostgreSQL column and table names are case-folded to lowercase unless quoted.
"TableName"is different fromtablename. - You connected to the wrong database (e.g.,
postgresinstead ofappdb). - The table was accidentally dropped or never created by a migration.
- The user does not have
USAGEprivilege on the schema containing the table.
How to Fix It
1. List all tables in the current database
psql -d yourdb
\dt2. List tables across all schemas
\dt *.*3. Check the current search_path
SHOW search_path;4. Use a fully qualified name
SELECT * FROM public.table_name;5. Set the search path to include your schema
SET search_path TO my_schema, public;6. Verify you are in the correct database
\conninfoFAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro