FluentDBFluentDB
PostgreSQL errors

PostgreSQL: relation "..." does not exist

ERRORSQLSTATE 42P01undefined_table
ERROR: relation "<name>" does not exist

Postgres could not resolve the table, view, or sequence you named. The three usual causes are a schema that is not on your search_path, a case-sensitivity mismatch from a quoted name, or a migration that has not run. Qualify the name or fix the search_path.

What this error means

In Postgres, "relation" means a table, view, materialized view, or sequence. This error is the parser telling you it cannot find an object by that name in any schema currently on your search_path.

Case matters more than people expect. Postgres folds unquoted identifiers to lowercase, so a table created as "Users" (with double quotes) is stored as Users, but SELECT * FROM Users looks for users and fails.

How to fix it

01

The table is in a schema not on your search_path

Schema-qualify the name, or add its schema to the search_path for your session.

sql
-- qualify it:
SELECT * FROM analytics.events;

-- or set the path:
SET search_path TO analytics, public;
02

The name was created with quotes and has mixed case

If the object was created as "MyTable", you must quote it the same way every time, otherwise Postgres lowercases it.

sql
SELECT * FROM "MyTable";
03

You are not sure it exists at all

Check directly. to_regclass returns NULL instead of erroring if the object is missing.

sql
SELECT to_regclass('analytics.events');  -- NULL means it is not there
-- or list tables in psql:
\dt analytics.*
04

The migration that creates it has not run

Confirm you are connected to the right database, then run your pending migrations.

How to avoid it next time

  • Prefer all-lowercase, unquoted identifiers so case never bites you.
  • Set search_path explicitly in your connection or role, rather than relying on the default.

Frequently asked questions

What counts as a 'relation' in Postgres?

A table, view, materialized view, or sequence. The error uses the general term because the same lookup covers all of them.

Why does my table work in one tool but not another?

Different clients can connect with a different search_path or even a different database. If one sees the table and another does not, compare their search_path and connection target.

Why does a capitalized table name fail?

Postgres lowercases unquoted identifiers. A table created as "Orders" only matches when you write "Orders" with double quotes every time.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.