DROP_SCHEMA(7pg18)
๐ 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 EXISTSoption, which is a PostgreSQL extension
so yeah, mostly a good citizen, just with a couple of extra sprinkles. โจ
๐ง SEE ALSO ๐ง
ALTER SCHEMA(ALTER_SCHEMA(7))CREATE SCHEMA(CREATE_SCHEMA(7))
(create it, alter it, drop it. the full character arc. ๐)
โญ quick vibe check before you go:RESTRICTis the default,CASCADEis 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
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms