DROP_RULE(7pg15)
π 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 π
CREATE RULE(CREATE_RULE(7))ALTER RULE(ALTER_RULE(7))
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
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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