tablespace “…” does not exist
SQLSTATE 42704 condition undefined_object class 42 — Syntax Error or Access Rule Violation severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.
Symptoms
A statement referenced a tablespace that does not exist. PostgreSQL raises SQLSTATE 42704 (undefined_object).
- The named tablespace isn’t defined in the cluster.
- Common in
CREATE TABLE … TABLESPACEorALTER … SET TABLESPACE. - Tablespaces are cluster-wide objects.
What the server log shows
ERROR: tablespace "fastdisk" does not exist
Why PostgreSQL raises this — what the manual says
the CREATE TABLESPACE reference (Description):
“A tablespace allows superusers to define an alternative location on the file system where the data files containing database objects (such as tables and indexes) can reside.”
Tablespaces are named, cluster-wide storage locations. Referencing one that was never created (or a typo) cannot be resolved, so PostgreSQL reports 42704.
Common causes
- The tablespace was never created.
- A typo in the tablespace name.
- Restoring a dump that assumes a tablespace not present here.
How to fix it
- Create it:
CREATE TABLESPACE fastdisk LOCATION '/mnt/fast';(superuser). - List tablespaces:
\dbor querypg_tablespace. - When restoring, pre-create needed tablespaces or remap with
--no-tablespaces.
Related & next steps
Reference: PostgreSQL 18 — CREATE TABLESPACE.