Skip to main content
Version: 2.0.0 (latest)

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.

ch3.rule-dialog.general123

General
#FieldDescription
1Event

Event that executes the rule. The possible values are ON SELECT, ON INSERT, ON UPDATE, and ON DELETE.

2Execution type

Mode in which the rule is executed. ALSO indicates that the commands stored in the rule are executed in addition to the original command that fired the rule. INSTEAD indicates that the commands stored in the rule are executed in place of the original one.

3Conditional expression

A SQL conditional expression that returns a boolean value (WHERE clause). The expression can't reference any table other than NEW and OLD, and can't contain aggregate functions.

ch3.rule-dialog.sql-commands12

SQL commands
#FieldDescription
1SQL command

A SQL command executed by the rule. Type it and use the add button to include it in the list.

2SQL commands

The commands executed by the rule. Type a command in the field above and click the add button to include it in the list; when the list is empty, the rule is generated with NOTHING as its action.

References​

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