Using LOCK TABLE Statement in Oracle

This Oracle tutorial explains how to use the Oracle LOCK TABLE announcement with syntax and examples.

Description

The LOCK TABLE assertion is used to lock tables, table partitions, or desk subpartitions.

Syntax

The syntax for the LOCK TABLE statement is:

LOCK TABLE tables IN lock_mode MODE [ WAIT [, integer] | NOWAIT ];

Parameters or Arguments

tables A comma-delimited list of tables. lock_mode It is one of the following values: lock_mode Explanation ROW SHARE Allows concurrent access to the table, however users are prevented from locking the entire table for distinctive access. ROW EXCLUSIVE Allows concurrent get right of entry to to the table, but users are avoided from locking the complete table with different get entry to and locking the desk in share mode. SHARE UPDATE Allows concurrent get entry to to the table, however users are prevented from locking the whole table for specific access. SHARE Allows concurrent queries but users are avoided from updating the locked table. SHARE ROW EXCLUSIVE Users can view information in table, but are avoided from updating the table or from locking the desk in SHARE mode. EXCLUSIVE Allows queries on the locked table, but no different activities. WAIT It specifies that the database will wait (up to a positive variety of seconds as targeted by integer) to accumulate a DML lock. NOWAIT It specifies that the database have to now not wait for a lock to be released.

Example

Let’s seem to be at an instance of how to use the LOCK TABLE assertion in Oracle.

For example:

LOCK TABLE suppliers IN SHARE MODE NOWAIT;

This example would lock the suppliers table in SHARE MODE and not wait for a lock to be released.