行级锁是保持的,但是insert不受影响
begin tran
insert into student select 2,'aa'
这句执行完后
spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
51 7 0 0 DB S GRANT
51 7 2105058535 0 RID 1:15:0 X GRANT
51 7 0 0 PAG 1:15 IX GRANT
51 1 85575343 0 TAB IS GRANT
51 7 2105058535 0 TAB IX GRANT
行级锁行保留着
begin tran
insert into student with(holdlock) select 6,'kk'
这句执行完后结果和上面一样
spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
51 7 0 0 DB S GRANT
51 7 2105058535 0 RID 1:15:0 X GRANT
51 7 0 0 PAG 1:15 IX GRANT
51 1 85575343 0 TAB IS GRANT
51 7 2105058535 0 TAB IX GRANT
begin tran
select * from student
这句执行完之后
spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
51 7 0 0 DB S GRANT
51 1 85575343 0 TAB IS GRANT
行级锁解除了
begin tran
select * from student with(holdlock)
这句执行完之后
spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
51 7 0 0 DB S GRANT
51 1 85575343 0 TAB IS GRANT
51 7 2105058535 0 TAB S GRANT
共享锁还保留着
26403021 sql群 博客 blog./user15/81152/index.shtml