DROP RULE
remove a rewrite rule
English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- anchor
- SQL-DROPRULE
- file
- sql-droprule.html
- lang
- en
- name
- DROP RULE
- purpose
- remove a rewrite rule
- purpose zh
- 移除一条重写规则
- sections same as
- Unknown
- slug
- 18
- synopsis html
- DROP RULE [ IF EXISTS ] <em class="replaceable"><code>name</code></em> ON <em class="replaceable"><code>table_name</code></em> [ CASCADE | RESTRICT ]
- synopsis text
- DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
Syntax
DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]Syntax diagrams
Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.
Definition PG 18
DROP RULE [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
Description
DROP RULE drops a rewrite rule.
Parameters
IF EXISTSDo not throw an error if the rule does not exist. A notice is issued in this case.
nameThe name of the rule to drop.
table_nameThe name (optionally schema-qualified) of the table or view that the rule applies to.
CASCADEAutomatically drop objects that depend on the rule, and in turn all objects that depend on those objects (see Section 5.15).
RESTRICTRefuse to drop the rule if any objects depend on it. This is the default.
Examples
To drop the rewrite rule newrule:
DROP RULE newrule ON mytable;
Compatibility
DROP RULE is a PostgreSQL language extension, as is the entire query rewrite system.
See Also
CREATE RULE, ALTER RULECompare versions
Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:91428225795fcdc200031569d5301e9c1269f130742b66dc955fedf2766ae42b
Text language: en · wiki-repair-20261023:91428225795fcdc200031569d5301e9c1269f130742b66dc955fedf2766ae42b