Contents Index Practical locking implications tutorial Objects that can be locked

ASA SQL User's Guide
  Using Transactions and Isolation Levels

How locking works


When the database server processes a transaction, it can lock one or more rows of a table. The locks maintain the reliability of information stored in the database by preventing concurrent access by other transactions. They also improve the accuracy of result queries by identifying information which is in the process of being updated.

The database server places these locks automatically and needs no explicit instruction. It holds all the locks acquired by a transaction until the transaction is completed, for example by either a COMMIT or ROLLBACK statement, with a single exception noted in Early release of read locks.

The transaction that has access to the row is said to hold the lock. Depending on the type of lock, other transactions may have limited access to the locked row, or none at all.

Obtaining information about locks on a table 

You can use the sa_locks system procedure to list information about locks that are held in the database. For more information, see sa_locks system procedure.

You can also view locks in Sybase Central. Select the database in the left pane, and a tab called Table Locks appears in the right pane. For each lock, this tab shows you the connection ID, user ID, table name, lock type, and lock name.


Objects that can be locked
Types of locks
Locking during queries
Locking during inserts
Locking during updates
Locking during deletes
Two-phase locking
Early release of read locks
Special optimizations

Contents Index Practical locking implications tutorial Objects that can be locked