Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

LOCK TABLE

Use the LOCK TABLE statement to control access to a table by other processes.

This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

Read syntax diagramSkip visual syntax diagram>>-LOCK TABLE--+-table---+--IN--+-SHARE-----+--MODE------------><
               '-synonym-'      '-EXCLUSIVE-'
 

Element Description Restrictions Syntax
synonym Synonym for the table to be locked Synonym and the table to which it points must exist Database Object Name
table Table to be locked See first paragraph of Usage. Database Object Name

Usage

You can use LOCK TABLE to lock a table if either of the following is true:

The LOCK TABLE statement fails if the table is already locked in EXCLUSIVE mode by another process, or if you request an EXCLUSIVE lock while another user has locked the same table in SHARE mode.

The SHARE keyword locks a table in shared mode. Shared mode gives other processes read access to the table but denies write access. Other processes cannot update or delete data if a table is locked in shared mode.

The EXCLUSIVE keyword locks a table in exclusive mode. This mode denies other processes both read and write access to the table. Exclusive-mode locking automatically occurs during the ALTER INDEX, ALTER TABLE, CREATE INDEX, DROP INDEX, RENAME COLUMN, RENAME TABLE, START VIOLATIONS TABLE, STOP VIOLATIONS TABLE, and TRUNCATE statements.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]