Skip to main content
Version: 1.1.0

3.6. Rules

Rules are objects that store additional SQL commands executed whenever a select, insert, delete or update is performed on a table. Unlike triggers, which can be executed on each row modification, rules are executed when the entire table is changed no matter how many rows were modified.

AttributeDescription
EventEvent that will execute the rule. Possible values are ON SELECT, ON DELETE, ON UPDATE, and ON TRUNCATE.
Execution TypeMode in which the rule must be executed. If ALSO is used, it indicates that the commands stored in the rule must be executed in addition to the original one (that fired the rule). If INSTEAD is used then the commands stored will be executed in place of the original one.
Conditional ExpressionA simple SQL conditional expression that returns a boolean value. The expression can't reference any tables as well as use aggregate functions.
CommandsThis group of fields is used to handle the commands executed by the rule.

References​

Rule DDL

https://www.postgresql.org/docs/current/static/sql-createrule.html