↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQL Commands

DROP TABLESPACE

remove a tablespace

English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

anchor
SQL-DROPTABLESPACE
file
sql-droptablespace.html
lang
en
name
DROP TABLESPACE
purpose
remove a tablespace
purpose zh
移除一个表空间
sections same as
Unknown
slug
18
synopsis html
DROP TABLESPACE [ IF EXISTS ] <em class="replaceable"><code>name</code></em>
synopsis text
DROP TABLESPACE [ IF EXISTS ] name

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

Definition PG 18

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

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:d4651b319dc4f0e508f8030e9738b1bf2e445f38633a73da423e57f17bed742a

Text language: en · wiki-repair-20261023:d4651b319dc4f0e508f8030e9738b1bf2e445f38633a73da423e57f17bed742a