// PostgreSQL error reference

PostgreSQL 3F000: schema does not exist

A statement names a schema that isn't in the current database, or creates an object when no schema on the search_path exists.

SQLSTATE
3F000
Name
invalid_schema_name
Category
Invalid Schema Name
Error message
schema "sales" does not exist

What it means

Schemas are namespaces inside one database. 3F000 means the schema named in a qualified name (sales.orders) or in SET search_path doesn't exist in the database you're connected to. Schema names follow the same case rules as other identifiers: unquoted names fold to lower case.

A related case is no schema has been selected to create in, when CREATE TABLE runs with a search_path that contains no existing schema.

Common causes

  • The schema hasn't been created in this database (each database has its own schemas).
  • A quoted mixed-case schema name such as "Sales" referenced without quotes.
  • Connected to the wrong database.
  • A search_path that names only schemas that don't exist.

How to fix it

  1. List the schemas in this database.

    SELECT nspname FROM pg_namespace ORDER BY nspname;
  2. Create the schema, optionally owned by the application role.

    CREATE SCHEMA IF NOT EXISTS sales AUTHORIZATION app;
  3. Point the search path at schemas that exist.

    SET search_path TO sales, public;

Reproduce it safely

SELECT * FROM no_such_schema.t;  -- ERROR: schema "no_such_schema" does not exist

Related errors

The code and message text are from the PostgreSQL documentation, Appendix A: PostgreSQL Error Codes. Browse the full PostgreSQL error list or search every database error.

// fewer errors, faster fixes

Work on PostgreSQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for PostgreSQL and the other databases you use.