 |
» |
|
|
 |
 |
 |

5.16 Describe the share (s) and exclusive (x) lock mode types
Key points
- There are two basic requirements of locking:
- READ operations (such as
SELECT and FETCH), must acquire SHARE locks
before rows can be retrieved.
- WRITE operations (such as
UPDATE, INSERT, and DELETE), must acquire
EXCLUSIVE locks before rows can be modified.
- A SHARE (S) lock permits reading by other users. No other transaction may
modify the data that is locked with an S lock.
- When an S lock is obtained at the table level, the transaction can read
all rows in the table. No row or page level locks are acquired when the
transaction reads a row (the S lock at the table level covers all of the rows
in the table, so additional locks are not neccessary).
- When an S lock is obtained at the page level, the transaction can read
all rows on the page. No row level locks are acquired when the transaction
reads a row (the S lock at the page level covers all of the rows on the page).
- When an S lock is obtained at the row level, the transaction can read the
row.
- An EXCLUSIVE (X) lock prevents access by any other user. An X lock is
the strongest type of lock. No other transaction may read or modify the data
that is locked with an X lock. An X lock must be obtained (either at the
table, page, or row level) when user data is updated, inserted, or deleted.
- When an X lock is obtained at the table level, the transaction can read and
modify all rows in the table. No row or page level locks are acquired when
the transaction reads or modifies a row.
- When an X lock is obtained at the page level, the transaction can read and
modify all rows on the page. No row level locks are acquired when the
transaction reads or modifies a row.
- When an X lock is obtained at the row level, the transaction can read and
modify the row.

Page last updated on November 29, 1995
|
|
|