What is Trigger?
A trigger is also a stored procedure that automatically executes when an event happens on a given table or view.
The database users only having the TRIGGER privilege for the given <subject_table_name> are allowed to create a trigger for that table or view.
The CREATE TRIGGER command defines a set of statements that are executed when a given operation (INSERT/UPDATE/DELETE) takes place on a given subject table or subject view.
CREATE TRIGGER <trigger_name> <trigger_action_time> <trigger_event_list> ON <subject_table_name> [REFERENCING <transition_list>] [<for_each_row>] BEGIN [<trigger_decl_list>] [<proc_handler_list>] <trigger_stmt_list> END
|<trigger_name>||It specifies the name of the trigger to be created, with the optional schema name.|
|<trigger_action_time>||BEFORE | AFTER | INSTEAD OF|
• BEFORE - Specifies that the trigger will be executed before the DML
Operation on a table. • AFTER - Specifies that the trigger will be executed after the DML operation
on a table. • INSTEAD OF - Specifies that the trigger will be executed instead of the DML
operation on a view. A view with INSTEAD OF trigger becomes updatable.