Parameter · Client Connection Defaults / Statement Behavior
default_tablespace
Sets the default tablespace to create tables and indexes in. An empty string means use the database's default tablespace.
- Default:
'' (empty) - Type: string
- Applies: Session (any user)
In plain words
A tablespace is a folder on disk where PostgreSQL can put tables. This setting chooses where new tables and indexes go when CREATE does not say. Empty (default) means the database's own default tablespace.
For DBAs and operators
Applies to CREATE TABLE, CREATE INDEX, and to indexes created for primary key and unique constraints. Not used for temporary objects: see temp_tablespaces. The user needs CREATE privilege on the tablespace. Setting a name that does not exist fails immediately for a session SET: ERROR: invalid value for parameter "default_tablespace": "nosuch" (from postgresql.conf the name is accepted without a check, and ALTER DATABASE/ROLE … SET only gives a NOTICE; a name that does not exist then means the database's default tablespace).
pg_dump emits SET default_tablespace = … before objects to place them correctly; restoring onto a server without that tablespace fails unless you use --no-tablespaces.
Moving existing objects is a separate operation (ALTER TABLE … SET TABLESPACE, which rewrites and locks the table). Tablespaces are not a backup or high-availability unit: losing one loses the cluster.
How to change it
Any user can change it for their session with SET.