Rule system

Creating a rule will either rewire the default rule or create a new rule for specific action on a specific table or view. In other words, a rule on an insert action can change the insert action's behavior or create a new action for insert. When using the rule system, note that it is based on the C macro system. This means that you 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 suppose 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 of the actions on the car table, such as UPDATE, DELETE, and INSERT ...

Get Learning PostgreSQL 11 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.