Skip to content

Table Does Not Exist

Error message

                relation does not exist
              

Quick summary

Your query references a table name that the database does not know about — it may be misspelled, in a different schema, or not yet created.

Why this happens

  • Typo in the table name

  • The table has not been created yet (missing CREATE TABLE / migration)

  • The table is in a different schema and you did not qualify it

  • You are connected to the wrong database

Minimal example

✗ Broken code
SELECT * FROM usres;
-- Typo: 'usres' instead of 'users'
✓ Fixed code
SELECT * FROM users;

The table name usres does not exist — fixing the typo to users resolves the error.

How to diagnose

  • Check the spelling of the table name in your query

  • List all tables to verify the table exists: \dt in psql or SHOW TABLES in MySQL

  • Check which database you are connected to

  • If using schemas, qualify the table name: schema.table_name

How to fix

  • Fix the typo to match the actual table name

  • Run the migration or CREATE TABLE script to create the table

  • Connect to the correct database

  • Qualify the table name with its schema

How to prevent

  • Use an ORM or query builder that validates table names at compile time

  • Keep migrations under version control and run them before deploying

  • Use consistent naming conventions for tables

Related Resources

Related Glossary

Related Lessons

  • Tables

    Learn how to create and reference tables.

← Back to language