Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Database triggers let you implement logic that enforces behaviors like database constraints. They let you restrict column-level and row-level behaviors and allow you to implement external constraints. These external constraints aren’t limited to referential integrity through foreign key constraints.
Database triggers also don’t let you perform table-level constraints, because they’re run after a DML statement begins a transaction against a table. DML statements change the content of tables and fire triggers in the first phase of a two-phase commit (2PC) operation. DML statements also leave the change in an uncommitted state, which means the table is mutating, or undergoing change.
You define triggers to run when an event occurs against a table. Two types of triggers can be defined: statement- and row-level triggers. Triggers have limited options that govern how they act against data in their assigned table. Statement-level triggers can’t do anything to the data inside their assigned tables, but row-level triggers can perform the following: