Skip Headers
Oracle® Database PL/SQL User's Guide and Reference
10g Release 2 (10.2)

Part Number B14261-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

LOCK TABLE Statement

The LOCK TABLE statement locks entire database tables in a specified lock mode. That enables you to share or deny access to tables while maintaining their integrity. For more information, see "Using LOCK TABLE".

Oracle has extensive automatic features that allow multiple programs to read and write data simultaneously, while each program sees a consistent view of the data; you should rarely, if ever, need to lock tables yourself. For additional information on the LOCK TABLE SQL statement, see Oracle Database SQL Reference.

Syntax

lock table statement ::=

Description of lock_table_statement.gif follows
Description of the illustration lock_table_statement.gif

Keyword and Parameter Description

table_reference

A table or view that must be accessible when you execute the LOCK TABLE statement. For the syntax of table_reference, see "DELETE Statement".

lock_mode

The type of lock. It must be one of the following: ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE, SHARE, SHARE ROW EXCLUSIVE, or EXCLUSIVE.

NOWAIT

This optional keyword tells Oracle not to wait if the table has been locked by another user. Control is immediately returned to your program, so it can do other work before trying again to acquire the lock.

Usage Notes

If you omit the keyword NOWAIT, Oracle waits until the table is available; the wait has no set limit. Table locks are released when your transaction issues a commit or rollback. A table lock never keeps other users from querying a table, and a query never acquires a table lock. If your program includes SQL locking statements, make sure the Oracle users requesting locks have the privileges needed to obtain the locks. Your DBA can lock any table. Other users can lock tables they own or tables for which they have a privilege, such as SELECT, INSERT, UPDATE, or DELETE.

Examples

This statement locks the employees table in row shared mode with the NOWAIT option: LOCK TABLE employees IN ROW SHARE MODE NOWAIT;

Related Topics


"COMMIT Statement"
"ROLLBACK Statement"