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.

The following table shows the types of locks that the lock table can contain.
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 their possible intent to lock an item, so that other users cannot place a lock on the item.

Depending on the type of operation and the isolation level, the database server might continue to read the row and place its own lock on the row, or it might wait for the lock to be released (if the user executed SET LOCK MODE TO WAIT). The following table shows the locks that a user can place if another user holds a certain type of lock. For example, if one user holds an exclusive lock on an item, another user requesting any kind of lock (exclusive, update, or shared) receives an error.
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