You can use the REPLACE TRIGGER statement to modify a trigger. This topic describes how to modify a trigger.
Syntax
To modify a trigger, you can use only the REPLACE TRIGGER statement, which is a DDL statement.
Generally, you can use the following syntax to create or modify a trigger:
CREATE OR REPLACE TRIGGER trigger_name ...
Note
If the value of
trigger_namedoes not exist, the trigger is created. If the value oftrigger_nameexists, the trigger is modified.
Examples
View the trigger
DEL_NEW_REGION.obclient> SELECT TRIGGER_BODY FROM USER_TRIGGERS WHERE TRIGGER_NAME='DEL_NEW_REGION'\G *************************** 1. row *************************** TRIGGER_BODY: TRIGGER del_new_region BEFORE DELETE ON regions FOR EACH ROW WHEN (old.region_id >3) BEGIN INSERT INTO reg_his(region_id , region_name ) VALUES( :old.region_id, :old.region_name ); END 1 row in setModify the trigger
DEL_NEW_REGION. Change the data deletion logic fromregion_id >3toregion_id >2for the DEL_NEW_REGION trigger.client> CREATE OR REPLACE TRIGGER del_new_region BEFORE DELETE ON regions FOR EACH ROW WHEN (old.region_id >2) BEGIN INSERT INTO reg_his(region_id , region_name) VALUES( :old.region_id, :old.region_name ); END; / Query OK, 0 rows affected, 1 warningView the
DEL_NEW_REGIONtrigger again.client> CREATE OR REPLACE TRIGGER del_new_region BEFORE DELETE ON regions FOR EACH ROW WHEN (old.region_id>2) BEGIN INSERT INTO reg_his(region_id , region_name ) VALUES( :old.region_id, :old.region_name ); END; / Query OK, 0 rows affected, 1 warning