A trigger is a database object that can perform a set of actions in response to events such as an INSERT, UPDATE, or DELETE operation on a specified table or view. You can use triggers, along with referential constraints and CHECK constraints, to enforce data integrity rules.
Five major components are associated with any trigger:
- The subject on which the trigger is defined–tables or views
- The event which initiates the trigger–an INSERT, UPDATE, or DELETE operation
- The activation time of the trigger–a BEFORE or AFTER the event
- The granularity which specifies whether the trigger's actions are performed once for the statement or once for each of the affected rows–a FOR EACH STATEMENT or FOR EACH ROW action
- The action, which the trigger performs–one or more of the following elements:
- CALL statement
- DECLARE and/or...