U鎖哪裡去了本文由一個問題引發:http://www.windbi.com/showtopic-404.ASPx
問題描述:
Create table tb1(a int ,b int)
Insert into tb1 values(1,2)
Insert into tb1 values(2,3)
Insert into tb1 values(3,4)
Create unique clustered index K_a on tb1(a)
Create table tb2(a int ,b int)
Insert into tb2 values(1,2)
Insert into tb2 values(2,3)
Insert into tb2 values(3,4)
Create unique nonclustered index X_a on tb2(a)
建立兩個連接A與B
A連接中執行:
Begin tran
Update tb1 set b=b+1 where a=1
B連接中同樣執行:
Begin tran
Update tb1 set b=b+1 where a=1
B連接會處於鎖等待狀態,運行sp_lock看一下:
52 10 0 0 DB S GRANT
52 10 2073058421 1 PAG 1:89 IX &nbs