DROP_SCHEMA(7pg14)
πΈ NAME πΈ
DROP_SCHEMA β remove a schema, bestie. This is the DROP_SCHEMA(7pg14) page from the PostgreSQL 14.24 docs, and it's giving very βschema deletion but make it clearβ energy β¨
β¨ SYNOPSIS β¨
okay so the syntax is literally:
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
no cap, that's the whole shape of it π«Ά
π DESCRIPTION π
DROP SCHEMA removes schemas from the database. That's the main character move here π
A schema can only be dropped by its owner or a superuser. And heads up: the owner can drop the schema β and thereby all contained objects β even if they do not own some of the objects within the schema. That's the important lore, bestie π«
π PARAMETERS π
IF EXISTSβ do not throw an error if the schema does not exist. A notice is issued in this case, so you get a lil heads-up instead of a whole error moment πnameβ the name of a schema. Yep, that's the target π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.14). This is the full-send option π₯RESTRICTβ refuse to drop the schema if it contains any objects. This is the default, so it's the safe lil default vibe π
π¦ NOTES π¦
Using the CASCADE option might make the command remove objects in other schemas besides the one(s) named. So yes, it can reach beyond the schema you named β keep that on your radar, bestie π
π EXAMPLES π
To remove schema mystuff from the database, along with everything it contains, you'd do:
DROP SCHEMA mystuff CASCADE;
iconic, clean, and very βbye schemasβ π§
π COMPATIBILITY π
DROP SCHEMA is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. So it's standard-approved with a little PostgreSQL plot twist β¨
β SEE ALSO β
ALTER SCHEMA(ALTER_SCHEMA(7))CREATE SCHEMA(CREATE_SCHEMA(7))
also go check those out, they're literally the sibling pages π«Ά
okay that's the whole DROP_SCHEMA(7pg14) situation π
β this page comes from the PostgreSQL 14.24 docs, dated 2026, and that's the cute little source/version + date sign-off, bestie π«Άβ¨
π¦ 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