Types of Triggers:
Triggers are categories into different types depending on when the trigger is to be fired. They are given below:
BEFORE / AFTER
The BEFORE option of a trigger is used to specify when the trigger must be fired. If the option BEFORE is selected, the trigger is fired before the triggering statement is executed. In the AFTER case, the trigger is fired after executing the statement.
When to Use Before and After
BEFORE
Before triggers are used when the triggering action determines whether the triggering statement must be permitted to be completed or not. That eliminates un-necessary processing of the triggering statement. A Before triggers could also be used to derive specific column values before completing an Update or Insert statement.
AFTER
This trigger is executed after the trigger statement is issued. When the trigger statement has to be completed it is used before the trigger action. An After trigger can be used to perform variant actions on the similar statement if a Before Trigger is already present.
Based on how many records are to be affected through the trigger, triggers can be classified as;
- Row Level
- Statement Level