DROP_RULE(7pg13)

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

πŸ’… DROP RULE πŸ’…

okay so real talk, this is the DROP RULE(7) page from the PostgreSQL 13.23 docs, and yes we're gonna make it cute and accurate. rules are literally the main character of the rewrite system, and this one's about saying bye to them πŸ‘‹


✨ NAME ✨

DROP_RULE β€” remove a rewrite rule. that's it, that's the whole vibe. she deletes a rule. periodt. πŸ’€


πŸ¦‹ SYNOPSIS πŸ¦‹

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

look at her. so clean. so structured. iykyk 🌸


πŸŽ€ DESCRIPTION πŸŽ€

DROP RULE drops a rewrite rule. no cap, that's literally it β€” you point at a rule, you point at the table it lives on, and poof, it's gone 🫢


πŸ’– PARAMETERS πŸ’–

  • IF EXISTS β€” bestie, this is the "don't yell at me" button. don't throw an error if the rule doesn't exist. instead, a notice is issued in this case. so you still get told, just gently πŸ™ˆ
  • name β€” the name of the rule to drop. that's the one you're breaking up with πŸ’”
  • table_name β€” the name (optionally schema-qualified) of the table or view that the rule applies to. yes, tables or views. both iconic, both valid ✨
  • CASCADE β€” the "and take everyone with you" option. automatically drop objects that depend on the rule, and in turn all objects that depend on those objects (see Section 5.14). it's giving domino effect, it's giving chain reaction πŸ”₯ heads up: this cascades in both directions of dependency, so read Section 5.14 before you get bold
  • RESTRICT β€” the responsible friend 🧚 refuse to drop the rule if any objects depend on it. this is the default, so if you don't say anything, this is what you get. safe, sensible, slay πŸ’…

🌈 EXAMPLES 🌈

to drop the rewrite rule newrule:

DROP RULE newrule ON mytable;

one line. one rule. gone. ate and left no crumbs πŸ‘‘


⭐ COMPATIBILITY ⭐

DROP RULE is a PostgreSQL language extension, as is the entire query rewrite system. so like, this isn't standard SQL β€” it's a whole PostgreSQL original, homegrown, built different πŸ’œ


πŸ“ SEE ALSO πŸ“

  • CREATE RULE (CREATE_RULE(7)) β€” for when you want a rule back in your life
  • ALTER RULE (ALTER_RULE(7)) β€” for when you're not ready to commit to deleting her

fr fr, if you're unsure whether anything depends on your rule, go check Section 5.14 first instead of letting CASCADE decide your fate 😭

and that's the page!! πŸŽ€ brought to you by PostgreSQL 13.23, dated 2025, besties πŸ’– go drop your rules responsibly, mwah 🫢✨

πŸ“¦ where this page comes from