一个单表死锁的示例

准备数据,插入1w条数据

create  table locktest(id int primary key identity(1,1))
go
begin tran
insert locktest default values
go 10000
commit

执行顺序如下,在第三部的时候会出现死锁

执行顺序 session1 session2
1

begin tran
delete from locktest where id=2

 
2  

set transaction isolation level repeatable read
begin tran
select * from locktest where id<3

3

delete from locktest where id=1

 
     
posted on 2011-07-19 12:48  stswordman  阅读(755)  评论(1编辑  收藏  举报