DROP_SCHEMA(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… DROP_SCHEMA โ€” the "remove a schema" manual page, bestie edition โœจ

okay so this is the DROP SCHEMA page from the PostgreSQL 18.6 Documentation (manual page DROP SCHEMA(7), yes we're being fancy with the section number ๐ŸŽ€). Buckle up, it's short but it's powerful, and powerful things deserve respect. ๐Ÿซถ


โœจ SYNOPSIS โœจ

DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

that's it. that's the whole vibe. one line, infinite chaos potential ๐ŸŒˆ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

DROP SCHEMA removes schemas from the database. bye bestie ๐Ÿ‘‹

Now here's the part you actually need to know: a schema can only be dropped by its owner or a superuser. So if it's not yours, don't touch it, no cap.

And here's the plot twist that lowkey eats: the owner can drop the schema (and thereby all contained objects) even if they don't own some of the objects inside that schema. like. the way that one command can take out stuff you don't technically own?? it's giving main character energy and also mild menace ๐Ÿ’€. so be careful, fr fr.


๐ŸŒธ PARAMETERS ๐ŸŒธ

  • IF EXISTS โ€” don't throw an error if the schema doesn't exist. instead a notice gets issued. so it's like, "girl, that schema wasn't even there" but politely. ๐Ÿ™ˆ
  • name โ€” the name of a schema. that's the thing you're yeeting. โœจ
  • CASCADE โ€” automatically drop objects (tables, functions, etc.) that are contained in the schema, and in turn all objects that depend on those objects (see Section 5.15). it's the domino effect option. one tap, whole tower falls. ๐Ÿข๐Ÿข๐Ÿข
  • RESTRICT โ€” refuse to drop the schema if it contains any objects. and bestie, this is the default. so if you don't say anything, Postgres is gonna be the responsible friend holding your hand. ๐Ÿ’œ

๐Ÿ’€ NOTES ๐Ÿ’€

Using the CASCADE option might make the command remove objects in other schemas besides the one(s) named.

like. you pointed at one schema and it took out stuff somewhere else entirely. not me realizing cascade has a reach that long ๐Ÿ˜ญ read twice, drop once.


๐ŸŽ€ EXAMPLES ๐ŸŽ€

To remove schema mystuff from the database, along with everything it contains:

DROP SCHEMA mystuff CASCADE;

iconic. devastating. extremely on purpose. ๐Ÿ”ฅ


๐Ÿ‘‘ COMPATIBILITY ๐Ÿ‘‘

DROP SCHEMA is fully conforming with the SQL standard, except that:

  • the standard only allows one schema to be dropped per command (we allow more, we're generous like that ๐Ÿ’…)
  • apart from the IF EXISTS option, which is a PostgreSQL extension

so yeah, mostly a good citizen, just with a couple of extra sprinkles. โœจ


๐Ÿงš SEE ALSO ๐Ÿงš

(create it, alter it, drop it. the full character arc. ๐ŸŒˆ)


โญ quick vibe check before you go: RESTRICT is the default, CASCADE is the one that takes no prisoners, and only the owner or a superuser gets to run this at all. that's the whole page. you're welcome bestie ๐Ÿซถ

mwah ๐Ÿ’– this has been the DROP SCHEMA(7) page, straight outta PostgreSQL 18.6, dated 2026. go forth and drop responsibly, my little schema destroyer. ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from