Lock Question - lock "U" against lock "X"

I have a couple of questions regarding Update (U) locks and exclusive (X) locks.

1) Do I correct that the lock "X" is placed on the resource when the resource is about to be updated?

2) I'm a little fuzzy on U-locks. I will fix that U lock applies when reading a resource, and SQL Server thinks that you might need to update the resource later? If this is correct, will the "U" lock only apply when reading is performed in the context of a transaction? I assume that I'm trying to understand the circumstances under which SQL Server believes that it might be necessary to update the row that it just read.

Thanks - Randy

+5
source share
1 answer

1) Do I correct that the lock "X" is placed on the resource when the resource is about to be updated?

Yes.

2) I'm a little fuzzy on U-locks. I will fix that U lock applies when reading a resource, and SQL Server thinks that you might need to update the resource later? If this is correct, will the "U" lock only apply when reading is performed in the context of a transaction? I assume that I'm trying to understand the circumstances under which SQL Server believes that it might be necessary to update the row that it just read.

Ulocks are compatible with read locks, but not with each other; locks Xare incompatible even with read locks.

U DML (UPDATE, DELETE, MERGE), ( ), X , .

READ COMMITTED , , .

+4

All Articles