【向All提问】锁的问题,请解析一下。
--表ta建有复合主键pk_ta(a,b)
--在连接1执行以下语句:
create table ta(a int not null, b int not null, c int, constraint pk_ta primary key(a,b))
insert ta
select 1,2,3 union all
select 1,3,4
begin tran
select * from ta with(xlock)
-- rollback tran
-- sp_lock
-- drop table ta
--在另一连接中分别执行以下查询:
select * from ta --1,无阻塞
select * from ta where a=1 --2, 无阻塞
select * from ta where b=1 --3, 被阻塞
select * from ta where c=1 --4, 被阻塞
请问为什么第3,4句会被阻塞呢?