Creates triggers for a specified table. A trigger defines the
actions to occur before or after the table is updated (by a write
operation such as an INSERT, DELETE, or UPDATE statement). The
trigger is associated with a single table, takes effect at a
specific time for a particular type of update, and causes one or
more triggered actions to be performed. If the trigger specifies
multiple actions, each action is performed in the order in which
it appears within the trigger definition.
With triggers, you can define useful actions such as:
o Cascading deletes
Deleting a row from one table causes additional rows to be
deleted from other tables that are related to the first table
by key values.
o Cascading updates
Updating a row in one table causes additional rows to be
updated in other tables that are related to the first table
by key values. These updates are commonly limited to the key
fields themselves.
o Summation updates
Updating a row from one table causes a value in a row of
another table to be updated by being increased or decreased.
o Hidden deletes
Causing rows to be deleted from a table by moving them to a
parallel table that is not otherwise used by the database.
NOTE
Combinations of table-specific constraints and appropriately
defined triggers, by themselves, are not sufficient to
guarantee that database integrity is preserved when the
database is updated. If integrity is to be preserved,
table-specific constraints and triggers must be used in
conjunction with a common set of update procedures that
ensure completely reproducible and consistent retrieval and
update strategies.
The CREATE TRIGGER statement adds the trigger definition to the
physical database.
A triggered action consists of an optional predicate and some
triggered statements. If specified, the predicate must evaluate
to true for the triggered statements in the action to execute.
Each triggered statement is executed in the order in which it
appears within the triggered action clause.
The triggered statement can be:
o A DELETE statement
o An UPDATE statement
o An INSERT statement
o A CALL statement
o A SIGNAL statement
o A TRACE statement
o An ERROR statement
Additional Information:
explode
extract