The following articles detail the distribution of update locks and exclusive locks during the update operation.
Http://blog.csdn.net/zjcxc/article/details/27351779
According to the tracing method described in the above article, we found that in the article lock (2) -- in the process of creating and updating tables, we use sys. the results of the dm_tran_locks dynamic view are the final locking results, but the changes in the locks are not reflected. If you want to know the lock changes in detail, you can still use the profile method.
In order to enhance my impression and understanding, I will test myself again:
-- This process is 64. first create a table and initialize five data records, and then update the data in the transaction create table dbo. TB (C1 int, C2 char (10), C3 varchar (10); godeclare @ ID int; Set @ ID = 0; while @ ID <5 begin; set @ ID = @ ID + 1; insert DBO. TB values (@ ID, 'B' + right (10000 + @ ID, 4), 'C' + right (100000 + @ ID, 4); end; begin tranupdate DBO. TB set C2 = 'xx' where c1 = 2; waitfor delay '00: 00: 30'; update DBO. TB set C2 = 'xx' where c1 = 5; -- rollback;
-- Process 66: Start a transaction and update a record in the TB table begin tranupdate DBO. TB set C2 = 'xx' where c1 = 1; rollback;
The tracing in profile is as follows: