DROP_TABLESPACE(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… 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_tablespaces setting of any active session, the DROP might 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 πŸ‘‘

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