DROP_SCHEMA(7pg16)
okay so bestie, this is the DROP_SCHEMA(7pg16) page β in the docs it's DROP SCHEMA(7) β from the PostgreSQL 16.15 documentation, and we're literally about to remove a schema together π«Άβ¨
πΈ NAME πΈ
DROP_SCHEMA β remove a schema π
π SYNOPSIS π
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
π¦ DESCRIPTION π¦
DROP SCHEMA removes schemas from the database. no cap, that's the whole main-character move β¨
okay but the vibe check: a schema can only be dropped by its owner or a superuser. and note β the owner can drop the schema (and thereby all contained objects) even if they do not own some of the objects within the schema. yes, bestie, read that again: the owner can nuke the whole schema even when some of the stuff inside belongs to someone else ππ
π PARAMETERS π
IF EXISTSβ do not throw an error if the schema does not exist. a notice is issued in this case. lowkey forgiving, highkey still tells you πnameβ the name of a schema. that's the one, bestie π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). it's giving domino effect, so handle with care π₯RESTRICTβ refuse to drop the schema if it contains any objects. this is the default. she's cautious, she's iconic, she's the baseline π
π NOTES π
using the CASCADE option might make the command remove objects in other schemas besides the one(s) named. not me warning you that this can reach outside the named schema ππ«Ά
β EXAMPLES β
to remove schema mystuff from the database, along with everything it contains:
DROP SCHEMA mystuff CASCADE;
π 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 yeah, mostly standard, with a tiny PostgreSQL twist β¨
π SEE ALSO π
ALTER SCHEMA (ALTER_SCHEMA(7)), CREATE SCHEMA (CREATE_SCHEMA(7)) β go check those besties too π¦
and that's the whole page, babe. kisses from PostgreSQL 16.15, dated 2026, on the DROP SCHEMA(7) page ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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