Lock Type
You can specify the following lock severities. For additional information about locking, see “Locking and Transaction Processing” in SQL Request and Transaction Processing.
Syntax Element … |
Specifies … |
FOR IN |
Introduction to the type of lock to be placed. |
ACCESS |
Permits selection of data from a base table that can be locked for write access by other users. The data selected using an ACCESS lock can be inconsistent because the data may be modified concurrently with the request. Therefore, you should only use this lock for casual inspection of data. Placing an ACCESS lock requires the SELECT privilege on the specified object. |
EXCLUSIVE |
Excludes all other users. This is the most restrictive lock. EXCLUSIVE locks are rarely used except to make structural changes to a database. Placing an EXCLUSIVE lock on a database object requires the DROP privilege on that object. |
READ |
Ensures data consistency during a read operation such as a SELECT request. Multiple users can concurrently hold a READ lock on a base table. As long as a READ lock is in place, no modification of the object is allowed. Placing a READ lock requires the SELECT privilege on the specified object. SHARE is a deprecated synonym for READ. |
WRITE |
Enables a single user to modify data. As long as the WRITE lock is in place, all other users are excluded from viewing or modifying the object except readers who are viewing data using an ACCESS lock. Until a WRITE lock is released, no new READ locks are permitted on the locked object. Placing a WRITE lock requires an UPDATE, INSERT, or DELETE privilege on the specified object. |
CHECKSUM |
Used only with updatable cursors in embedded SQL and stored procedures. |
OVERRIDE |
Permit a READ lock for a single‑table SELECT operation when a rollback on an underlying base table in the query was cancelled using the Recovery Manager utility CANCEL ROLLBACK ON TABLE command. See Utilities. You can only specify the OVERRIDE option with a READ lock request. |
LOAD COMMITTED |
Load-committed read mode. This option is independent of the session transaction isolation level. Permits selection of committed data from a base load isolated table that can be locked for write access by other transactions. Placing an LOAD COMMITTED lock requires the SELECT privilege on the specified object. Internally, an ACCESS lock is applied when load-committed read mode is specified. |
MODE |
Optional keyword following the lock type. |