CREATE TRIGGER statement [T-SQL]
480
CREATE TRIGGER statement [T-SQL]
Use this statement to create a new trigger in the database in a manner
compatible with Adaptive Server Enterprise.
CREATE TRIGGER [
owner
.]
trigger_name
… ON [
owner
.]
table_name
… FOR { INSERT, UPDATE, DELETE }
… AS
…
statement-list
CREATE TRIGGER [
owner
.]
trigger_name
… ON [
owner
.]
table_name
… FOR {INSERT, UPDATE}
… AS
… [ IF UPDATE (
column_name
)
… [ { AND | OR} UPDATE (
column_name
) ] … ]
…
statement-list
… [ IF UPDATE (
column_name
)
… [ { AND | OR} UPDATE (
column_name
) ] … ]
…
statement-list
Must have RESOURCE authority and have ALTER permissions on the table,
or must have DBA authority.
CREATE TRIGGER locks all the rows on the table, and thus requires
exclusive use of the table.
Automatic commit.
"CREATE TRIGGER statement" on page 477
The rows deleted or inserted are held in two temporary tables. In the
Transact-SQL form of triggers, they can be accessed using the table names
deleted, and inserted, as in Adaptive Server Enterprise. In the Watcom-SQL
CREATE TRIGGER statement, these rows are accessed using the
REFERENCING clause.
Trigger names must be unique in the database.
Transact-SQL triggers are executed AFTER the triggering statement.
♦
SQL/92 Transact-SQL extension.
♦
Sybase Anywhere supports a subset of the Adaptive Server Enterprise
syntax.
Function
Syntax 1
Syntax 2
Permissions
Side effects
See also
Description
Standards and
compatibility