窗口1: begin tran select * from tab with(rowlock,xlock) where groupname=8 窗口2: select * from tab 结果窗口2出来的是tab的全部数据,在窗口1中不是给groupname=8的 行加了排它锁,为什么还会出来全部数据呢???? 在tab中没加任何索引
--sqlserver2000 SP3下
----生成测试环境
create table tab (
id int,
groupname int
)
insert tab select 1,8
union all
select 2,7
union all
select 3,6
union all
select 4,9
go
---窗口1
begin tran
select * from tab with(rowlock,xlock) where groupname=8
waitfor delay '0:00:05'
commit tran
---窗口2
select * from tab
---窗口2结果(在1执行完后出来)
id groupname
1 8
2 7
3 6
4 9
---窗口2
select * from tab with(readpast)
---窗口2结果(立刻显示)
id groupname
2 7
3 6
4 9