The trigger is defined as an Apex code that executes to perform custom actions, before or after modifications like insert, update, delete, etc. that has done to records in Salesforce.
Triggers can be defined for top-level standard objects, like contact or account, custom objects, and few standard child objects. They are active by default when created. When the specified database events occur, Salesforce automatically fires active triggers.
The syntax for creating a trigger is given below:
trigger TriggerName on ObjectName (trigger_events)
To execute a trigger before or after insert, update, delete and undelete operations, specify multiple trigger events like before insert, before delete, after insert, after update etc. in a comma-separated list.