Trigger and rule systems
PostgreSQL provides triggers and rule systems to automatically perform a certain function when an event, such as INSERT, UPDATE, or DELETE, is performed. Triggers and rules cannot be defined on SELECT statements, except for _RETURN, which is used in the internal implementation of PostgreSQL views.
From a functionality point of view, the trigger system is more generic; it can be used to implement complex actions more easily than rules. However, both trigger and rule systems can be used to implement the same functionalities in several cases. From a performance point of view, rules tend to be faster than triggers, but triggers tend to be simpler and more compatible with other RDBMs, since the rule system is a PostgreSQL ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access