Rename Trigger
This Article will help you to understand “RENAME Trigger” with example and it’s detailed description.
ALTER TRIGGER statement used to RENAME the trigger.
Example
We will create table “electricity_bill”.
Then create trigger “trg_rename_example” on electricity_bill table.
We will check the trigger status from “USER_TRIGGERS” table.
Then we will RENAME trigger by ALTER TRIGGER statement and then check again the USER_TRIGGERS table. You will notice new name of trigger in output.
Code
0 1 2 3 4 5 6 7 8 |
--Creating electricity_bill table. create table electricity_bill ( bill_id number(5) primary key, amount number(5) ); |
Output
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
-- Creating TRIGGER CREATE OR REPLACE TRIGGER trg_rename_example BEFORE UPDATE OR DELETE OR INSERT ON electricity_bill FOR EACH ROW BEGIN -- business logic will be here to perform on any insert/update/delete dbms_output.put_line('trg_rename_example Trigger called.'); END; / |
Output
0 1 2 |
SELECT TABLE_NAME,TRIGGER_NAME FROM USER_TRIGGERS WHERE upper(TABLE_NAME) = 'ELECTRICITY_BILL'; |
TABLE_NAME | TRIGGER_NAME |
---|---|
ELECTRICITY_BILL | TRG_RENAME_EXAMPLE |
0 1 2 3 4 |
--RENAME TRIGGER ALTER TRIGGER trg_rename_example RENAME TO trg_name_updated; |
Output
Now again check the USER_TRIGGERS table.
0 1 2 |
SELECT TABLE_NAME,TRIGGER_NAME FROM USER_TRIGGERS WHERE upper(TABLE_NAME) = 'ELECTRICITY_BILL'; |
TABLE_NAME | TRIGGER_NAME |
---|---|
ELECTRICITY_BILL | TRG_NAME_UPDATED |