↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQL Commands

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.

DROP RULE IF EXISTS name ON table_name CASCADE RESTRICT

Definition PG 18

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

Description

DROP RULE drops a rewrite rule.

Parameters

IF EXISTS

Do not throw an error if the rule does not exist. A notice is issued in this case.

name

The name of the rule to drop.

table_name

The name (optionally schema-qualified) of the table or view that the rule applies to.

CASCADE

Automatically drop objects that depend on the rule, and in turn all objects that depend on those objects (see Section 5.15).

RESTRICT

Refuse 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 RULE

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:91428225795fcdc200031569d5301e9c1269f130742b66dc955fedf2766ae42b

Text language: en · wiki-repair-20261023:91428225795fcdc200031569d5301e9c1269f130742b66dc955fedf2766ae42b