Removes a tablespace from the system.
Prerequisites
Before dropping a tablespace, confirm that:
You are the tablespace owner or a superuser.
The tablespace contains no database objects — including objects from other databases that may still reside in it.
No active session lists the tablespace in its
temp_tablespacessetting. Temporary files in the tablespace might cause the drop to fail.
Syntax
DROP TABLESPACE [ IF EXISTS ] nameParameters
| Parameter | Description |
|---|---|
IF EXISTS | Does not throw an error if the tablespace does not exist. A notice is issued instead. |
name | The name of the tablespace to drop. |
Usage notes
DROP TABLESPACE cannot run inside a transaction block.
Examples
Drop a tablespace:
DROP TABLESPACE mystuff;Drop a tablespace only if it exists:
DROP TABLESPACE IF EXISTS mystuff;