DROP_SCHEMA(7pg16)

πŸ“¦ version 16.15, in opensuse-leap 16.0

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