A database trigger is code that is executed in response to events that have been generated by database commands such as INSERT, DELETE, or UPDATE.
Triggers are code that are executed in response to events that have been generated before or after a database operation. They are sometimes separated as pre- and post-triggers in the literature. A pre-trigger can be used as an extra validation check before the database command is executed, whereas a post-trigger can be used as a notification that the database command has been executed.
Triggers can be classified according to trigger granularity: row-level triggers or statement-level triggers. In case of row-level triggers, each row will generate an event, whereas statement-level triggers occur only once per database command.