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

UNLOCK TABLE

Use the UNLOCK TABLE statement in a database that does not use implicit transactions to unlock a table that you previously locked with the LOCK TABLE statement. The UNLOCK TABLE statement is not valid within a transaction.

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

Syntax

Read syntax diagramSkip visual syntax diagram>>-UNLOCK TABLE--+-table---+-----------------------------------><
                 '-synonym-'
 

Element Description Restrictions Syntax
synonym Synonym for a table to unlock The synonym and the table to which it points must exist Database Object Name, p. Database Object Name
table Table to unlock Must be in a database without transactions and must be a table that you previously locked Database Object Name, p. Database Object Name

Usage

You can lock a table if you own the table or if you have the Select privilege on the table, either from a direct grant to yourself or from a grant to public. You can only unlock a table that you locked. You cannot unlock a table that another process locked. Only one lock can apply to a table at a time.

You must specify the name or synonym of the table that you are unlocking. Do not specify the name of a view, or a synonym for a view.

To change the lock mode of a table in a database without transactions, use the UNLOCK TABLE statement to unlock the table, then issue a new LOCK TABLE statement. The following example shows how to change the lock mode of a table in a database that was created without transactions:

LOCK TABLE items IN EXCLUSIVE MODE
...
UNLOCK TABLE items 
...
LOCK TABLE items IN SHARE MODE

The UNLOCK TABLE statement fails if it is issued within a transaction. Table locks set within a transaction are released automatically when the transaction completes.

If you are using an ANSI-compliant database, do not issue an UNLOCK TABLE statement. The UNLOCK TABLE statement fails if it is issued within a transaction, and a transaction is always in effect in an ANSI-compliant database.

Related Information

Related statements: BEGIN WORK, COMMIT WORK, LOCK TABLE, and ROLLBACK WORK

For a discussion of concurrency and locks, see the IBM Informix Guide to SQL: Tutorial.

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