3.6. Rules

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

Attribute Description
Event Event that will execute the rule. Possible values are ON SELECT, ON DELETE, ON UPDATE and ON TRUNCATE.
Execution Type Mode in which the rule must be executed. If ALSO is used 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 Expression A simple SQL conditional expression that returns a boolean value. The expression can't reference any tables as well use aggregate functions.
Commands This group of fields is used to handle the commands executed by the rule.

** Rule DDL **

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

Jan 3, 2020 at 12:33