oracle中使用触发器实现级联更新

来源:互联网 发布:linux中iconv命令 编辑:程序博客网 时间:2024/05/23 14:31

oracle中使用触发器实现级联更新这里使用的是scott用户下的自带表,大家可以测试下,测试可以用;

create or replace trigger tr_update_emp

after update of deptno on dept

for each row

begin

     update emp set deptno=:new.deptno where deptno=:old.deptno;

end;

如果想实现级联删除,可以再添加外键的时候加上on delete cascade

 ALTER TABLE table1
   ADD CONSTRAINT FK_groupcm_REFERENCE_commodity FOREIGN KEY (cmSeq)
      REFERENCES table2(CMSEQ);

原创粉丝点击