8
Triggers and Rules
In the previous chapter, we talked about server-side programming. In this chapter, we will use the concepts introduced in the previous chapter to manage the programming of events in PostgreSQL. The first thing we need to address is what an event in PostgreSQL actually is. In PostgreSQL, possible events are given by the SELECT
/INSERT
/UPDATE
, and DELETE
statements. There are also events related to data definition language (DDL) operations; however we will talk about those events in Chapter 17, Event Triggers.
In PostgreSQL, there are two ways to handle events:
- Rules
- Triggers
In this chapter, we will explore both of these ways and address when it is more appropriate to use one rather than the other. As a starting point, we ...
Get Learn PostgreSQL - 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.