ITPub博客

首页 > 数据库 > Oracle > 搭建死锁场景

搭建死锁场景

原创 Oracle 作者:csbin 时间:2012-03-30 10:43:57 0 删除 编辑

-- ① 创建表
create table tab_a (id number, name varchar2(255));
create table tab_b (id number, name varchar2(255));


-- ② 初始化数据
insert into tab_a values(1,'csb');
insert into tab_b values(1,'csb');


-- ③ 创建触发器
create or replace trigger trg_tab_b
  after insert or update on tab_b for each row
declare
  pragma autonomous_transaction;
begin
  update tab_a t set t.id = :new.id;
  commit;
end;
/


-- ④ 制造死锁
begin
  update tab_a t set t.id = t.id;
  update tab_b t set t.id = t.id;
end;
/

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

上一篇: 广州
请登录后发表评论 登录
全部评论

注册时间:2009-01-12

  • 博文量
    69
  • 访问量
    1479823