when/what locks are hold/released in READ COMMITTED isolation level

前端 未结 4 1682
小蘑菇
小蘑菇 2020-12-14 18:32

I am trying to understand isolation/locks in SQL Server.

I have following scenario in READ COMMITTED isolation level(Default)

We have a table.



        
4条回答
  •  感情败类
    2020-12-14 19:10

    lock will only acquire when select * from Transaction is run

    You can check it with below code

    open a sql session and run this query

    Begin Transaction
    
    select * from Transactions
    
     WAITFOR DELAY '00:05'
    /*
    some buisness logic which takes 5 minutes
    
    */
    
    Commit
    

    Open another sql session and run below query

    Begin Transaction
    Update Transactions
    Set = ...
    where ....
    commit
    

提交回复
热议问题