日期:2014-05-18  浏览次数:20456 次

问大家一把死锁的问题,在线等!!!!急急急!!!!
设table1(A,B,C)  
A B C
a1 b1 c1
a2 b2 c2
a3 b3 c3 
增设table2(D,E)
D E
d1 e1
d2 e2


我这样产生一个死锁
begin tran
update table1 set A='aa' where B='b2'  
waitfor delay '00:00:30'
update table2 set D='d5' where E='e1'  
commit tran

在第二个连接中执行以下语句
begin tran
update table2 set D='d5' where E='e1'  
waitfor delay '00:00:10'
update table1 set A='aa' where B='b2'  
commit tran 

请问
1:大家能帮我解释一下,为什么上面这样能产生死锁, 死锁后是这样一直挂着吗????
2:产生死锁后,我想查询表1或2中的一条记录,,可以查询吗


------解决方案--------------------
1.为啥会死锁,请看数据库最基础的书。
死锁之后,会出现牺牲,也就是其中一个事务被 数据库 自动干掉了。
2.死锁之后可以查任何东西 不影响