The internal lock table
The database server stores locks in an internal lock table. When the database server reads a row, it checks if the row or its associated page, table, or database is listed in the lock table. If it is in the lock table, the database server must also check the lock type.
Lock Type | Description | Statement That Usually Places the Lock |
---|---|---|
S | Shared lock | SELECT |
X | Exclusive lock | INSERT, UPDATE, DELETE |
U | Update lock | SELECT in an update cursor |
B | Byte lock | Any statement that updates VARCHAR columns |
A byte lock is generated only if you shrink the size of a data value in a VARCHAR column. The byte lock exists solely for roll forward and rollback execution, so a byte lock is created only if you are working in a database that uses logging. Byte locks appear in onstat -k output only if you are using row-level locking; otherwise, they are merged with the page lock.
In addition, the lock table might store intent locks, with the same lock type as previously shown. In some cases, a user might need to register his or her possible intent to lock an item, so that other users cannot place a lock on the item.
Hold X lock | Hold U lock | Hold S lock | |
---|---|---|---|
Request X lock | No | No | Yes |
Request U lock | No | No | Yes |
Request S lock | No | Yes | Yes |