create trigger

Description

Creates a trigger, which is a type of stored procedure that is often used for enforcing integrity constraints. A trigger executes automatically when a user attempts a specified data modification statement on a specified table.

Syntax

create trigger [owner.]trigger_name 
on [owner.]table_name 
for {insert, update, delete} 
as SQL_statements

Or, using the if update clause:

create trigger [owner.]trigger_name 
on [owner.]table_name 
for {insert, update} 
as 
    [if update (column_name) 
        [{and | or} update (column_name)]...] 
        SQL_statements
    [if update (column_name) 
        [{and | or} update (column_name)]... 
        SQL_statements]...

Usage

When a trigger is created on a proxy table, it will execute after an insert, delete or update statement on that proxy table completes. However, the special tables inserted and deleted, which normally are views into the local transaction log, will not contain any data, since changes to remote data are not logged locally.