ALTER TRIGGER
Go Up to Statement and Function Reference (Language Reference Guide)
Changes an existing trigger. Available in DSQL and isql
.
ALTER TRIGGER <name> [ACTIVE | INACTIVE]
[{BEFORE | AFTER} {DELETE | INSERT | UPDATE}]
[POSITION <number>]
[AS trigger_body] ;
Argument | Description |
---|---|
<name> |
Name of an existing trigger. |
|
[Default] Specifies that a trigger action takes effect when fired. |
|
Specifies that a trigger action does not take effect. |
|
Specifies the trigger fires before the associated operation takes place. |
|
Specifies the trigger fires after the associated operation takes place. |
|
Specifies the table operation that causes the trigger to fire. |
|
Specifies order of firing for triggers before the same action or after the same action.
|
<trigger_body> |
Body of the trigger: a block of statements in procedure and trigger language.
|
Description: ALTER TRIGGER
changes the definition of an existing trigger. If any of the arguments to ALTER TRIGGER
are omitted, then they default to their current values, that is the value specified by CREATE TRIGGER
, or the last ALTER TRIGGER
.
ALTER TRIGGER
can change:
- Header information only, including the trigger activation status, when it performs its actions, the event that fires the trigger, and the order in which the trigger fires compared to other triggers.
- Body information only, the trigger statements that follow the AS clause.
- Header and trigger body information. In this case, the new trigger definition replaces the old trigger definition.
A trigger can be altered by its creator, the SYSDBA user, and any users with operating system root privileges.
- Note: To alter a trigger defined automatically by a CHECK constraint on a table, use ALTER TABLE to change the constraint definition.
Examples: The following statement modifies the trigger, SET_CUST_NO
, to be inactive:
ALTER TRIGGER SET_CUST_NO INACTIVE;
The next statement modifies the trigger, SET_CUST_NO
, to insert a row into the table, NEW_CUSTOMERS
, for each new customer.
ALTER TRIGGER SET_CUST_NO FOR CUSTOMER BEFORE INSERT AS BEGIN NEW.CUST_NO = GEN_ID(CUST_NO_GEN, 1); INSERT INTO NEW_CUSTOMERS(NEW.CUST_NO, TODAY) END ;