win*_*ing 5 sql sql-server serialization transaction-isolation
我为事务设置了可序列化的事务隔离锁.但是我正在观察一些不期望的结果.
我的疑问是
update tabl1 set col2 = 10 where col1 > 10 and col1 < 20
Run Code Online (Sandbox Code Playgroud)
这里col1是主键.具有值10,11,12 .... 19,20的col1的行被锁定以进行更新/插入.在条件为i的条件下,col1> 10且col1 <20,但仍然有col1 = 10且col1 = 20的行被锁定.
如果我给
update tabl1 set col2 = 10 where col1 => 10 and col1 <= 20
Run Code Online (Sandbox Code Playgroud)
然后col2值为9到21的行被锁定.那么为什么col1有9和21被锁定在这里?
对于下面的查询,全表被锁定.这里col3是一个非主列.如果where条件中的列不是主键,我不能设置锁定吗?
update tabl1 set col2 = 10 where col3 > 10 and col3 < 20
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1721 次 |
| 最近记录: |