DROP_RULE(7pg18)
๐ DROP_RULE โ bestie edition
ok so like, hi. you're here for DROP_RULE(7) from the PostgreSQL 18.6 docs, and honestly? you came to the right place. this is the page about yeeting a rewrite rule into the void. let's get into it ๐
โจ NAME โจ
DROP_RULE โ remove a rewrite rule
like. it drops a rewrite rule. that's the whole vibe. it's giving "delete but make it SQL" ๐
๐ธ SYNOPSIS ๐ธ
DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
look at that. so clean. so demure. so mindful ๐ฆ
๐ DESCRIPTION ๐
DROP RULE drops a rewrite rule.
that's it. that's the sentence. the original docs really said "no thoughts, head empty, just vibes" and honestly? respect. it drops the rule, periodt. ๐
โจ PARAMETERS โจ
IF EXISTSโ do not throw an error if the rule doesn't exist. so if you're out here trying to drop a rule that's already gone, this flag is your emotional support bestie ๐ซถ. a notice gets issued in this case, so you'll still know what went down.nameโ the name of the rule to drop. you know. the one you want gone. the one that's been living rent-free in your schema. ๐table_nameโ the name (optionally schema-qualified) of the table or view that the rule applies to. yes bestie, views count too. don't forget it. ๐CASCADEโ automatically drop objects that depend on the rule, and in turn all objects that depend on those objects (see Section 5.15). it's giving domino effect, it's giving chain reaction, it's giving "you pulled one thread and the whole sweater is gone" ๐งต๐. use with intention, not on a whim.RESTRICTโ refuse to drop the rule if any objects depend on it. this is the default. she's cautious. she's protective. she said "not on my watch" ๐ก๏ธโจ
๐ฅ EXAMPLES ๐ฅ
to drop the rewrite rule newrule:
DROP RULE newrule ON mytable;
one line. no cap. ate and left no crumbs ๐ ๐
๐ COMPATIBILITY ๐
DROP RULE is a PostgreSQL language extension, as is the entire query rewrite system. so if you go looking for it in standard SQL, bestie... it's not there. it's a Postgres original. main character energy only ๐โจ
๐ฆ SEE ALSO ๐ฆ
CREATE RULE(CREATE_RULE(7))ALTER RULE(ALTER_RULE(7))
go read those too, iykyk. they're the prequel and the glow-up arc of this whole saga ๐ธ
ngl, the whole "drop the thing that drops the thing" pipeline is lowkey iconic and also highkey a little scary. CASCADE does not play. be safe out there. ๐ญ๐
mwah ๐ that's the page, bestie. this was PostgreSQL 18.6, dated 2026, and the man page you just read is literally titled DROP RULE(7). go forth and drop responsibly ๐โจ๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms