The size of a lock is called:
A. shared lock.
B. lock granularity
C. exclusive lock.
D. implicit lock.
Answer:A. shared lock.
Locking is a mechanism used by the Microsoft SQL Server Database Engine to synchronize access by multiple users to the same piece of data at the same time. The transaction does this by requesting a lock on the piece of data. Locks have different modes.
There are three lock modes:
A. shared lock.
B. lock granularity
C. exclusive lock.
D. implicit lock.
Answer:A. shared lock.
Locking is a mechanism used by the Microsoft SQL Server Database Engine to synchronize access by multiple users to the same piece of data at the same time. The transaction does this by requesting a lock on the piece of data. Locks have different modes.
There are three lock modes:
SHARED
Row-level shared locks allow multiple users to read data, but do not allow any users to change that data.
Table-level shared locks allow multiple users to perform read and write operations on the table, but do not allow any users to perform DDL operations.
Multiple users can hold shared locks simultaneously.
EXCLUSIVE
An exclusive lock allows only one user/connection to update a particular piece of data (insert, update, and delete). When one user has an exclusive lock on a row or table, no other lock of any type may be placed on it.
UPDATE
Update locks are always row-level locks. When a user accesses a row with the SELECT... FOR UPDATE statement, the row is locked with an update mode lock. This means that no other user can read or update the row and ensures the current user can later update the row.
Row-level shared locks allow multiple users to read data, but do not allow any users to change that data.
Table-level shared locks allow multiple users to perform read and write operations on the table, but do not allow any users to perform DDL operations.
Multiple users can hold shared locks simultaneously.
EXCLUSIVE
An exclusive lock allows only one user/connection to update a particular piece of data (insert, update, and delete). When one user has an exclusive lock on a row or table, no other lock of any type may be placed on it.
UPDATE
Update locks are always row-level locks. When a user accesses a row with the SELECT... FOR UPDATE statement, the row is locked with an update mode lock. This means that no other user can read or update the row and ensures the current user can later update the row.
Shared locks exist when two transactions are granted read access. One transaction gets the shared lock on data and when the second transaction requests the same data it is also given a shared lock. Both transactions are in a read-only mode, updating the data is not allowed until the shared lock is released.
No comments:
Post a Comment
What you have to say about this?