模拟试验之-外键未加索引导致死锁

session 1:

scott@TEST>create table p(x int primary key);
 
Table created.
 
scott@TEST>create  table c(x references p);
 
Table created.
 
scott@TEST>insert into p values(1);
 
1 row created.
 
scott@TEST>insert into p values(2);
 
1 row created.
 
scott@TEST>insert into p values(3);
 
1 row created.
 
scott@TEST>commit;
 
Commit complete.
 
scott@TEST>insert into c values(2);
 
1 row created.
 
scott@TEST>delete from p where x=1;
delete from p where x=1
            *
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource

 

session 2

scott@TEST>insert into c values(2);
 
1 row created.
 
scott@TEST>delete from p where x=3;

 

此时查看锁情况:

sys@TEST>l
  1  select addr,sid,type,id1,id2,lmode,request,block from v$lock where type in('TX','TM')
  2*
sys@TEST>/
 
ADDR            SID TY        ID1        ID2      LMODE    REQUEST      BLOCK
-------- ---------- -- ---------- ---------- ---------- ---------- ----------
5B9E4430         12 TX     196609        286          6          0          0
5B9A8978         12 TM       6339          0          3          0          1
5B9A88F4         12 TM       6337          0          2          0          0
5B9E405C         17 TX     458760        483          6          0          0
5B9A8A80         17 TM       6339          0          3          5          0
5B9A89FC         17 TM       6337          0          3          0          0
 

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

转载于:http://blog.itpub.net/10972173/viewspace-214858/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值