Contents
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
- PostgreSQL 8.2
DROP RULE IF EXISTS ...
syntax added (commit bbcd0169)
- PostgreSQL 7.3
- PostgreSQL 6.4
- made functional (initial commit 15cb32d9)
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
References
- PostgreSQL documentation: DROP RULE