Creating a rule will either rewire the default rule, or create a new rule for a specific action on a specific table or view. In other words, a rule on an insert action can change the insert action behavior, or can create a new action for the insert. When using the rule system, one needs to note that it is based on the C macro system. This means one can get strange results when it is used with volatile functions such as random(), and sequence functions such as nextval(). The following example shows how tricky the rule system can be. Let's assume that we would like to audit the table for car. For this reason, a new table called car_log will be created to keep a track of all the actions on the car table, such as UPDATE, DELETE, and ...
Rule system
Get Learning PostgreSQL 10 - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.