DROP_RULE(7pg15)

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

πŸ’… DROP_RULE (7pg15) β€” or, how to yeet a rewrite rule into the void ✨

okay so bestie, gather round, because today we're looking at DROP RULE from the PostgreSQL 15.19 docs (yes that's the DROP RULE(7) page, hi, welcome 🫢). It's a tiny page, it's an icon, and it does exactly one thing: it drops a rewrite rule. That's it. That's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]

🌸 DESCRIPTION 🌸

DROP RULE drops a rewrite rule. short king behavior honestly β€” no cap, that's literally the entire description πŸ’€πŸ’–

πŸ¦‹ PARAMETERS πŸ¦‹

  • IF EXISTS β€” do not throw an error if the rule doesn't exist. instead you just get a notice, which is the database equivalent of a soft launch πŸ™ˆ lowkey polite of it.
  • name β€” the name of the rule you're dropping. like, its actual name. the rule's name. 🏷️
  • table_name β€” the name of the table or view that the rule applies to. it can be schema-qualified if you're feeling fancy (optionally schema-qualified, their words not mine πŸ‘‘).
  • CASCADE β€” automatically drop objects that depend on the rule, and then in turn all objects that depend on those objects. yes it's giving chain reaction, yes it's iconic, and yes Section 5.14 is where the tea is spilled on that πŸ“–πŸ”₯
  • RESTRICT β€” refuse to drop the rule if any objects depend on it. this is the default, so if you don't say anything, it's already in RESTRICT mode protecting you πŸ›‘οΈβœ¨
⚠️ quick vibe check: CASCADE does not ask questions, it just takes everyone down with it. know that before you type it, bestie 😭

🌈 EXAMPLES 🌈

so you wanna drop the rewrite rule newrule? periodt. here's the whole thing:

DROP RULE newrule ON mytable;

look at her go πŸ§šπŸ’œ

⭐ COMPATIBILITY ⭐

DROP RULE is a PostgreSQL language extension β€” and so is the entire query rewrite system. so like, don't go looking for her in other databases, she's exclusive πŸ’…πŸ‘‘

πŸ“ SEE ALSO πŸ“

the holy trinity of rule management fr fr 🌸


and that's the page!! brought to you by PostgreSQL 15.19, dated 2026, signed sealed and delivered with love by your favorite DROP RULE(7) girlie πŸ’–πŸŽ€βœ¨ mwah!

πŸ“¦ where this page comes from