DROP_RULE(7pg13)
π 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 boldRESTRICTβ 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 lifeALTER 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
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms