Oracle PL/SQL – Rename Trigger

摘要: This article shows you how to use ALTER TRIGGER to rename a trigger.

This article shows you how to use ALTER TRIGGER to rename a trigger.

-- rename a trigger
ALTER TRIGGER original_name RENAME TO new_name;

1. Table + Trigger

electricity_bill
create table electricity_bill
  bill_id number(5) primary key,
  amount number(5)
);
-- Table ELECTRICITY_BILL created.
trg_rename_example
CREATE OR REPLACE TRIGGER trg_rename_example
BEFORE
     UPDATE OR DELETE OR INSERT
ON electricity_bill
  FOR EACH ROW 
BEGIN
  dbms_output.put_line('trg_rename_example Trigger called.');
END;
-- Trigger TRG_RENAME_EXAMPLE compiled

2. Rename Trigger example

2.1 Get all triggers belong to a specified table

SELECT TABLE_NAME,TRIGGER_NAME FROM USER_TRIGGERS WHERE upper(TABLE_NAME) = 'ELECTRICITY_BILL';
TRIGGER_NAME STATUS
ELECTRICITY_BILL TRG_RENAME_EXAMPLE

2.2 Rename a trigger.

ALTER TRIGGER trg_rename_example RENAME TO trg_name_updated;
-- output
-- Trigger TRG_RENAME_EXAMPLE altered.

2.3 Check the trigger name again.

SELECT TABLE_NAME,TRIGGER_NAME FROM USER_TRIGGERS WHERE upper(TABLE_NAME) = 'ELECTRICITY_BILL';
TRIGGER_NAME STATUS
ELECTRICITY_BILL TRG_NAME_UPDATED

References

  1. Oracle – ALTER TRIGGER
  2. Oracle – PL/SQL Triggers

上一篇: JPA Insert + Oracle Sequences example
下一篇: Spring Boot Show Hibernate SQL query
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章来源于互联网, 若有侵权, 联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布文章.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号