DROP_SCHEMA(7pg15)
π DROP_SCHEMA π
Okay bestie, this is the DROP SCHEMA(7) page from the PostgreSQL 15.19 docs, and itβs all about yeeting schemas out of your database. Letβs get into it β¨
πΈ NAME πΈ
DROP_SCHEMA β remove a schema
π SYNOPSIS π
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
π¦ DESCRIPTION π¦
DROP SCHEMA removes schemas from the database. Slay, but carefully π
A schema can only be dropped by its owner or a superuser. And just so you know: 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 rule, no cap.
β¨ PARAMETERS β¨
IF EXISTSβ Do not throw an error if the schema does not exist. A notice is issued in this case. So itβs like, βbestie, itβs not here, but we moveβ instead of a full error moment.nameβ The name of a schema. Literally the schemaβs name, periodt.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 βtake everything with itβ option π₯RESTRICTβ Refuse to drop the schema if it contains any objects. This is the default. Very βnope, not unless itβs emptyβ energy.
π NOTES π
Using theCASCADEoption might make the command remove objects in other schemas besides the one(s) named. So yeah,CASCADEcan reach outside the group chat β be aware, bestie π
π 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. Standard-ish, but make it PostgreSQL π
π SEE ALSO π
ALTER SCHEMA(ALTER_SCHEMA(7))CREATE SCHEMA(CREATE_SCHEMA(7))
PostgreSQL 15.19 β’ 2026 β’ DROP SCHEMA(7) β mwah, thatβs the page, bestie π«Άπβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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