DROP RULE

An SQL command for removing a rule

DROP RULE is a DDL command for removing a rule.

DROP RULE has always been present in PostgreSQL, although it only became properly functional from PostgreSQL 6.4.

Change history

Examples

Basic usage example for DROP RULE:

postgres=# DROP RULE foo_insert_rule ON foo;
DROP RULE

Attempting to drop a non-existent rule:

postgres=# DROP RULE foo_update_rule ON foo;
ERROR:  rule "foo_update_rule" for relation "foo" does not exist

Safely attempting to drop a rule which might not exist:

postgres=# DROP RULE IF EXISTS foo_insert_rule ON foo;
NOTICE:  rule "foo_insert_rule" for relation "foo" does not exist, skipping
DROP RULE

Categories

DDL, Rules, SQL command

See also

CREATE RULE, ALTER RULE