DROP_SCHEMA(7pg13)

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

🌸 NAME 🌸

okay so this page is DROP_SCHEMA(7pg13) from the PostgreSQL 13.23 docs, and it’s literally about removing a schema from the database. no cap. πŸ’…

✨ SYNOPSIS ✨

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

πŸ’– DESCRIPTION πŸ’–

DROP SCHEMA removes schemas from the database. that’s the whole vibe. 🫢

A schema can only be dropped by its owner or a superuser. main character permissions only, bestie. ✨ Note that the owner can drop the schema (and thereby all contained objects) even if they do not own some of the objects within the schema. like, yes, that’s a thing. 😭

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the schema does not exist. A notice is issued in this case. πŸŽ€
  • name β€” the name of a schema. simple as that. πŸ’–
  • 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 one goes hard, so be careful. πŸ”₯
  • RESTRICT β€” refuse to drop the schema if it contains any objects. this is the default. πŸ’…

πŸ¦‹ NOTES πŸ¦‹

Using the CASCADE option might make the command remove objects in other schemas besides the one(s) named. not a drill, bestie. lowkey sneaky. πŸ’€

🌈 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. slay for standards compliance, with one tiny asterisk. ⭐

πŸ”₯ SEE ALSO πŸ”₯


xoxo, PostgreSQL 13.23, 2025 β€” DROP_SCHEMA(7) out. πŸ’…βœ¨

πŸ“¦ where this page comes from