DROP_TABLESPACE(7pg13)

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

πŸ’… DROP_TABLESPACE(7pg13) β€” the "bye tablespace" glow-up

okay bestie, so this is the PostgreSQL 13.23 Documentation page for DROP_TABLESPACE, and it's literally the manual for yeeting a tablespace out of your system. very demure, very "get it off my server" energy. let's go πŸ¦‹


✨ NAME ✨

DROP_TABLESPACE β€” remove a tablespace πŸŽ€

✨ SYNOPSIS ✨

DROP TABLESPACE [ IF EXISTS ] name

that bracket situation around IF EXISTS means it's optional, iykyk πŸ’…

✨ DESCRIPTION ✨

so DROP TABLESPACE removes a tablespace from the system. periodt. πŸ—‘οΈ

but ngl, there are rules β€” and they are rules:

  • 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. like, fully empty. no sneaky leftovers πŸ™ˆ
  • heads up: objects in other databases might still reside in the tablespace, even if no objects in the current database are using it. so the vibe check has to happen across all your databases, fr fr 😭
  • 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 yeah, if your drop keeps failing β€” check for objects in other DBs and check temp_tablespaces on every active session. not me learning this the hard way 🫢

✨ PARAMETERS ✨

  • IF EXISTS β€” don't throw an error if the tablespace doesn't exist. instead a notice is issued in this case 🌸 (very "no thoughts, no error" of it)
  • name β€” the name of a tablespace. that's it, that's the parameter πŸ’œ

✨ NOTES ✨

DROP TABLESPACE cannot be executed inside a transaction block. no cap. don't try it, bestie 😀

✨ EXAMPLES ✨

to remove tablespace mystuff from the system:

DROP TABLESPACE mystuff;

iconic. ate. leaving no crumbs πŸ”₯

✨ COMPATIBILITY ✨

DROP TABLESPACE is a PostgreSQL extension. it's giving "we made this ourselves" ✨

✨ SEE ALSO ✨


and that's the whole page, bestie!! 🫢 this was PostgreSQL 13.23, dated 2025, and you're all caught up on DROP TABLESPACE. go forth and drop responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from