A trigger is a special type of stored program that fires
when a table is modified by an
DELETE (DML) statement. Triggers implement
functionality that must take place whenever a certain change occurs to
the table. Because triggers are attached directly to the table, application code
cannot bypass database triggers.
Typical uses of triggers include the implementation of critical business logic, the denormalization of data for performance reasons, and the auditing of changes made to a table. Triggers can be defined to fire before or after a specific DML statement executes.
In Figure 2-17, we
create a trigger that fires before any
INSERT statement completes against the
sales table. It automatically
applies free shipping and discounts to orders of a specified
Here is an explanation of the trigger definition:
Specify the trigger name.
Specify that the trigger fires
before an insert on the
Include the (currently) mandatory