The CREATE TRIGGER command defines and names
a trigger that will be stored in the database.
CREATE [ OR REPLACE ] TRIGGER name
{ BEFORE | AFTER } { INSERT | UPDATE | DELETE } [ OR { INSERT | UPDATE | DELETE } ]... ON
table
[ FOR EACH ROW ]
[DECLARE
declarations ]
BEGIN
statements
END;
name is the name of the trigger. If
[ OR REPLACE ] is specified and
a trigger with the same name already exists in the schema, the
new trigger replaces the existing one. If
[ OR REPLACE ] is not specified,
the new trigger will not be allowed to replace an existing one
with the same name in the same schema. If BEFORE
is specified, the trigger is defined as a before trigger. If
AFTER is specified, the trigger is defined as
an after trigger. One of INSERT,
UPDATE, or DELETE must be
specified defining the triggering event as an insert, update, or
deletion, respectively. One or both of the remaining triggering
event keywords may also be specified separated by the keyword,
OR, in which case these are also defined as
triggering events. table is the name
of the table on which a triggering event will cause the trigger
to fire. If [ FOR EACH ROW ]
is specified, the trigger is defined as a row-level trigger. If
[ FOR EACH ROW ] is omitted,
the trigger is defined as a statement-level trigger.
declarations are variable, cursor, or type
declarations. statements are
SPL program statements. The
BEGIN - END block may
contain an EXCEPTION section.