美文网首页
新、改、删 触发器

新、改、删 触发器

作者: 罗宏宇 | 来源:发表于2017-12-27 17:03 被阅读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;  

相关文章

网友评论

      本文标题:新、改、删 触发器

      本文链接:https://www.haomeiwen.com/subject/mhgugxtx.html