新、改、删 触发器

2017-12-27  本文已影响0人  罗宏宇

创建触发器

CREATE OR REPLACE TRIGGER "time_test_TR"
  AFTER INSERT OR UPDATE OR DELETE ON TIME_TEST
  FOR EACH ROW
BEGIN case
    when inserting then
      insert into TIME_TEST2
        (id, val, ctime)
      values
        (:new.id, :new.val, :new.ctime);
    when updating then
    
      update TIME_TEST2
         set val   = :new.val,
             ctime = :new.ctime
       where id = :new.id;
    when deleting then
    
      delete TIME_TEST2 where id = :old.id;
    
  end case;

END;

删除触发器

DROP TRIGGER "time_test_TR";  
ALTER TRIGGER "time_test_TR" ENABLE;  

上一篇 下一篇

猜你喜欢

热点阅读