测试DBLINK触发器事务

STEP1:在数据库TW中创表
conn system/passwd@tw;
create user test identified by test;
grant connect to test;
grant create table to test;
alter user test quota 1M on users;
----------------------
conn test/test@tw;
create table test(name varchar2(20));
insert into test values('from_tw');

 

STEP2:在数据库TW1中创表
conn system/passwd@tw1;
create user test identified by test;
grant connect to test;
grant create table to test;
alter user test quota 1M on users;
grant create trigger to test;
--------------------------
conn test/test@tw1;
create table test(name varchar2(20));
insert into test values('from_tw1');

 

STEP3:在TW1中建立DBLINK与触发器
create public database link totw connect to test identified by test using 'TW';
---------------------
create or replace trigger write_tw_test
after insert on test
referencing old as old new as new
for each row
begin
 insert into test.test@totw(name) values(:new.name);
 dbms_output.put_line('---inserting---');
end;
/

 

STEP4:演示

 

STEP5:结论
触发器的操作与触发的事件属于同一个事务,触发器与触发事件一起提交、回滚(DBLINK一样)
行级触发器在某行发生变化时触发,只有触发器做完它的操作,后面的事件才会继续进行(等待触发器完成)

 

STEP6:测试DBLINK中触发器是否工作(TW)
create or replace trigger read_insert
after insert on test
for each row
begin
 insert into test1 values('read_from_tw1');
end;
/ --工作

--容易造成等待触发器操作全部完成,与等待锁

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值