DROP_SCHEMA(7pg14)

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

🌸 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 ⭐

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