PostgreSQL 17.12Lab-verified · 2026-11-29

PostgreSQL error 3F000: schema does not exist

The statement names a schema that does not exist under that exact (case-folded) name.

PostgreSQL 17.12
3F000: schema "sales" does not exist

Jump to a cause

  1. 01CREATE TABLE in a schema that was not created yet
  2. 02The schema was created with quotes as "Sales"
  3. 03A typo in the schema name in GRANT

Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-29 · container image postgres:17

3F000 is raised when a statement explicitly needs a schema, for example CREATE TABLE schema.table or GRANT … ON SCHEMA, and PostgreSQL cannot find it. Unquoted names are folded to lowercase, so the schema in the message is always the lowercase form unless you quoted it.

The three causes below come up in migrations and setup scripts. In each test the fix was either creating, renaming, or spelling the schema correctly.

01CREATE TABLE in a schema that was not created yet

CREATE TABLE sales.orders (...) failed with 3F000: schema "sales" does not exist, and psql pointed at sales.orders.

After CREATE SCHEMA sales AUTHORIZATION lab_a (run as postgres), the same CREATE TABLE succeeded.

Reproducerun as lab_a
CREATE TABLE sales.orders (id int PRIMARY KEY, amount numeric);
✕ ERROR
ERROR:  3F000: schema "sales" does not exist
LINE 1: CREATE TABLE sales.orders (id int PRIMARY KEY, amount numeri...
                     ^
Fixrun as postgres
CREATE SCHEMA sales AUTHORIZATION lab_a;
OUTPUT
CREATE SCHEMA

Create the schema first in the migration. AUTHORIZATION makes the app role the owner, so it can create tables there.

After the fixrun as lab_a
CREATE TABLE sales.orders (id int PRIMARY KEY, amount numeric);
✓ SUCCESS
CREATE TABLE

02The schema was created with quotes as "Sales"

The schema was created as "Sales" (with quotes, as GUI tools often do). CREATE TABLE Sales.orders without quotes is read as sales, so it failed with schema "sales" does not exist.

pg_namespace showed the real name was Sales. After ALTER SCHEMA "Sales" RENAME TO sales, the same statement without quotes succeeded.

Setup
Setuprun as postgres
CREATE SCHEMA "Sales" AUTHORIZATION lab_a;
OUTPUT
CREATE SCHEMA
Reproducerun as lab_a
CREATE TABLE Sales.orders (id int PRIMARY KEY);
✕ ERROR
ERROR:  3F000: schema "sales" does not exist
LINE 1: CREATE TABLE Sales.orders (id int PRIMARY KEY);
                     ^
Checkrun as lab_a
SELECT nspname FROM pg_namespace WHERE lower(nspname) = 'sales';
OUTPUT
 nspname
---------
 Sales
(1 row)
Fixrun as postgres
ALTER SCHEMA "Sales" RENAME TO sales;
OUTPUT
ALTER SCHEMA

Alternatively keep the name and always write "Sales" in quotes. Renaming to lowercase means you never need quotes.

After the fixrun as lab_a
CREATE TABLE Sales.orders (id int PRIMARY KEY);
✓ SUCCESS
CREATE TABLE

03A typo in the schema name in GRANT

GRANT USAGE ON SCHEMA report TO lab_b failed with schema "report" does not exist. psql's \dn listed the actual schema as reports.

With the correct name, both GRANT USAGE ON SCHEMA reports and GRANT SELECT ON reports.daily succeeded.

Setup
Setuprun as postgres
CREATE SCHEMA reports AUTHORIZATION lab_a;
CREATE TABLE reports.daily (d date, total numeric);
ALTER TABLE reports.daily OWNER TO lab_a;
OUTPUT
CREATE SCHEMA
CREATE TABLE
ALTER TABLE
Reproducerun as lab_a
GRANT USAGE ON SCHEMA report TO lab_b;
✕ ERROR
ERROR:  3F000: schema "report" does not exist
Checkrun as lab_a
\dn
OUTPUT
       List of schemas
  Name   |       Owner
---------+-------------------
 app     | postgres
 lab_a   | lab_a
 lab_b   | lab_b
 public  | pg_database_owner
 reports | lab_a
(5 rows)
After the fixrun as lab_a
GRANT USAGE ON SCHEMA reports TO lab_b;
GRANT SELECT ON reports.daily TO lab_b;
✓ SUCCESS
GRANT
GRANT

FAQ

How do I fix schema does not exist in PostgreSQL?

Check the real name with \dn (or pg_namespace), then create it, rename it, or fix the spelling. All three fixes were tested on this page.

The schema exists but PostgreSQL says it does not. Why?

It was probably created with quotes in mixed case, like "Sales". Unquoted Sales is read as sales. In the test, pg_namespace showed Sales and the unquoted statement failed.

What is the difference between 3F000 and 42P01?

3F000 is about the schema (for example CREATE TABLE or GRANT ON SCHEMA naming a missing schema). 42P01 is about a missing table or view.

Who can create the schema?

A role with CREATE on the database, such as postgres. In the test postgres ran CREATE SCHEMA ... AUTHORIZATION lab_a so lab_a owned it.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12