DROP_TABLESPACE(7pg14)
π DROP_TABLESPACE π
okay so bestie, this is the DROP TABLESPACE page from the PostgreSQL 14.24 Documentation β the DROP TABLESPACE(7) one, yes, that one β and it's genuinely not that deep, let me walk you through it π«Ά
β¨ NAME β¨
DROP_TABLESPACE β remove a tablespace. that's it. that's the whole vibe. bye-bye tablespace π
π SYNOPSIS π
DROP TABLESPACE [ IF EXISTS ] name
like, that's literally the whole syntax. short king behavior fr fr π
π DESCRIPTION π
DROP TABLESPACE removes a tablespace from the system. bam. gone. no cap.
okay but here's the part where you have to pay attention, bestie, because the rules are kind of strict π
- a tablespace can only be dropped by its owner or a superuser β so like, know your role π
- the tablespace must be empty of all database objects before it can be dropped. it's giving "you can't move out until you've packed everything."
- and here's the sneaky part: it is possible that objects in other databases might still reside in the tablespace even if no objects in the current database are using it. so like, the vibe check is per-database but the consequences are global π
- also, if the tablespace is listed in the
temp_tablespacessetting of any active session, theDROPmight fail due to temporary files residing in the tablespace. so a random session could be holding your tablespace hostage with its little temp files. not me finding out like this π
πΈ PARAMETERS πΈ
IF EXISTSβ do not throw an error if the tablespace does not exist. a notice is issued in this case. it's the "no worries if not!" of SQL β¨nameβ the name of a tablespace. just... the name. that's the parameter. love that for us π
π¦ NOTES π¦
DROP TABLESPACE cannot be executed inside a transaction block. like, at all. ever. it's a main-character statement that refuses to be contained π₯
β EXAMPLES β
to remove tablespace mystuff from the system, you say:
DROP TABLESPACE mystuff;
and it's gone. slay. mystuff is no longer your stuff ππ
π COMPATIBILITY π
DROP TABLESPACE is a PostgreSQL extension. so if some other database is like "we don't have that," that's why. it's our thing, iykyk π
π SEE ALSO π
CREATE TABLESPACE(CREATE_TABLESPACE(7)) β for when you want to make oneALTER TABLESPACE(ALTER_TABLESPACE(7)) β for when you want to change one
like a whole little tablespace cinematic universe, we love a trilogy π«Ά
and that's the page, bestie!! go forth and drop responsibly, don't drop one that's still full of stuff, and remember: no transaction blocks allowed, periodt π β¨
ok bye, this was PostgreSQL 14.24, dated 2026 β mwah ππ§π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms