DROP_SCHEMA(7pg17)

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

πŸ’… DROP_SCHEMA(7) β€” remove a schema, bestie πŸ’…

🌸 NAME 🌸

DROP_SCHEMA β€” remove a schema. that’s the whole vibe, no cap.


✨ SYNOPSIS ✨

okay so here’s the syntax, bestie:

DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

πŸ¦‹ DESCRIPTION πŸ¦‹

so DROP_SCHEMA literally removes schemas from the database. iconic.

only the schema’s owner or a superuser can drop it. and yes, the owner can drop the schema β€” and by extension all contained objects β€” even if they don’t own some of the objects within the schema. the way that works is lowkey wild, but that’s the rule πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” don’t throw an error if the schema doesn’t exist. a notice is issued in this case.
  • name β€” the name of a schema.
  • CASCADE β€” auto-drops objects (tables, functions, etc.) contained in the schema, and then all objects that depend on those objects (see Section 5.15).
  • RESTRICT β€” refuse to drop the schema if it contains any objects. this is the default, bestie.

⭐ NOTES ⭐

heads up: using CASCADE might make the command remove objects in other schemas besides the one(s) you named. so like… be aware πŸ‘€


🌈 EXAMPLES 🌈

to remove schema mystuff from the database, along with everything it contains:

DROP SCHEMA mystuff CASCADE;

πŸ’œ COMPATIBILITY πŸ’œ

compatibility check, bestie: DROP_SCHEMA is fully conforming with the SQL standard β€” with two caveats: the standard only allows one schema to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. iykyk.


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’– that’s the whole DROP_SCHEMA tea β€” PostgreSQL 17.11, dated 2026. mwah, go be iconic with your schemas πŸ’…βœ¨

πŸ“¦ where this page comes from