ITPub博客

首页 > 数据库 > Oracle > oracle trigger 同步数据

oracle trigger 同步数据

原创 Oracle 作者:netwant 时间:2011-05-14 11:38:21 0 删除 编辑
oracle trigger[@more@]

昨天帮同事弄一个同步数据的触发器,搞了2个多小时,郁闷,心得就是不要听他们说的,要自己看看。因为他们也不知道做过什么,为了应付你就随便乱说,导致判断失误。还有就是哪个时候有点累,精神不够集中。哎,干IT也是体力精力的折磨呀。

u 在sqlplus中创建公共连接:

create public database link smsbak connect to smsadmin identified by smsadmin using ’bakup‘;

以表t为例,如下:

create or replace trigger t_trigger

after insert or update or delete on t

for each row

begin

if deleting then

delete from t@bakup where id=:old.id;

end if;

if inserting then

insert into t@bakup(ID, IC_ID, SUB_ID)

values(:new.id,:new.ic_id,:new.sub_id);

end if;

if updating then

update t@bakup set ic_id=:new.ic_id,sub_id=:new.sub_id where id=:old.id;

end if;

end a_b_test;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/309902/viewspace-1049849/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: oradebug
请登录后发表评论 登录
全部评论

注册时间:2010-11-17

  • 博文量
    61
  • 访问量
    180996