select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQL COMMANDS / DATABASES & SCHEMAS

DROP TABLESPACE

Read PG 18 manual ↗

remove a tablespace

Syntax

DROP TABLESPACE [ IF EXISTS ] name
Syntax diagrams

Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.

DROP TABLESPACE IF EXISTS name

Description

DROP TABLESPACE removes a tablespace from the system.

A tablespace can only be dropped by its owner or a superuser. The tablespace must be empty of all database objects before it can be dropped. It is possible that objects in other databases might still reside in the tablespace even if no objects in the current database are using the tablespace. Also, if the tablespace is listed in the temp_tablespaces setting of any active session, the DROP might fail due to temporary files residing in the tablespace.

Parameters

IF EXISTS

Do not throw an error if the tablespace does not exist. A notice is issued in this case.

name

The name of a tablespace.

Notes

DROP TABLESPACE cannot be executed inside a transaction block.

Examples

To remove tablespace mystuff from the system:

DROP TABLESPACE mystuff;

Compatibility

DROP TABLESPACE is a PostgreSQL extension.

See Also

CREATE TABLESPACE, ALTER TABLESPACE

Related entries

Definition snapshot: 2026-09-14T13:14:25.700916+00:00@99e6866c · English manual source