CREATE TRIGGER statement (basic)


The CREATE TRIGGER statement defines a new basic trigger.


createTrigger_bqu1525.png

CREATE TRIGGER schema.triggerName

This option specifies the fully qualified name of the trigger to be created.

OWNER triggerOwner

This option specifies the owner of the trigger.

TABLE tableOwner.tableName

This option specifies the triggering base table of the associated trigger or the name of the view for an INSTEAD OF trigger.

TBQUALIFIED

This option indicates whether the TABLE name was qualified in the CREATE TRIGGER statement.

TBQUALIFIED parameter values

Value

Description

YES

Indicates that the TABLE name was qualified

NO

Indicates that the TABLE name was not qualified

ACTIVATE

This option specifies whether the trigger is activated before or after the triggering event.

ACTIVATE parameter values

Value

Description

BEFORE

Specifies to activate the trigger before the event

AFTER

Specifies to activate the trigger after the event

INSTEAD OF

Specifies to activate the trigger instead of updating, inserting into, or deleting from a view

GRANULARITY

This option specifies whether Db2 executes the triggered action for each row or for each statement.

GRANULARITY parameter values

Value

Description

ROW

Specifies to execute the action for each row

STATEMENT

Specifies to execute the action for each statement

SECURED

This option specifies that the trigger is secured.

NOT SECURED

This option specifies that the trigger is not secured.

ONEVENT

This option specifies when Db2 executes the trigger.

ONEVENT parameter values

Value

Description

INSERT

Specifies to have Db2 execute the trigger when an insertion occurs

DELETE

Specifies to have Db2 execute the trigger when a deletion occurs

UPDATE ALLCOLUMNS

Specifies to have Db2 execute the trigger when an update occurs, and to update all of the columns in the table

UPDATE COLUMNS columnNameList

Specifies to have Db2 execute the trigger when an update occurs, and to update a list of columns in columnNameList

REFOLDCORR correlationName

This option specifies the OLD AS correlation name.

REFNEWCORR correlationName

This option specifies the NEW AS correlation name.

REFOLDTB identifier

This option specifies the OLD _TABLE AS identifier.

REFNEWTB identifier

This option specifies the NEW_TABLE AS identifier.

COMMENT 'string'

This option specifies the comment for the trigger.

PATH (schemaList)

This option specifies the path for the trigger.

TRIGGERTEXT (triggerText)

This option specifies the triggered action for the trigger.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*