Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Statements

LOAD TABLE statement Next Page

LOCK TABLE statement

Use this statement to prevent other concurrent transactions from accessing or modifying a table.


LOCK TABLE table-name


table-name    The table must be a base table, not a view. As temporary table data is local to the current connection, locking global or local temporary tables has no effect.

WITH HOLD clause    If this clause is specified, the lock is held until the end of the connection. If the clause is not specified, the lock is released when the current transaction is committed or rolled back.

SHARE mode    Prevent other transactions from modifying the table, but allow them read access. Transactions can change data while in SHARE mode, provided no other transaction holds a lock of any kind on the row(s) being modified.

EXCLUSIVE mode    Prevent other transactions from accessing the table. No other transaction can execute queries, updates of any kind, or any other action against the table. If a table t is locked exclusively with a statement such as LOCK TABLE t IN EXCLUSIVE MODE, the default server behavior is to not acquire row locks for t. This behavior can be disabled by setting the subsume_row_locks option to Off.


The LOCK TABLE statement allows direct control over concurrency at a table level, independent of the current isolation level.

While the isolation level of a transaction generally governs the kinds of locks that are set when the current transaction executes a request, the LOCK TABLE statement allows more explicit control locking of the rows in a table.


To lock a table in SHARE mode, SELECT privileges are required.

To lock a table in EXCLUSIVE mode; you must be the table owner or have DBA authority.

Side effects

Other transactions that require access to the locked table may be delayed or blocked.

See also
Standards and compatibility

The following statement prevents other transactions from modifying the Customers table for the duration of the current transaction:

LOCK TABLE Customers