Oracle 5.0 Reference Manual page 1135

Table of Contents

Advertisement

explicitly acquires table locks for the current client session. Table locks can be acquired
LOCK TABLES
for base tables or (as of MySQL 5.0.6) views. You must have the
the
[578]
privilege for each object to be locked.
SELECT
For view locking,
LOCK TABLES
and locks them automatically. If you lock a table explicitly with
triggers are also locked implicitly, as described in
explicitly releases any table locks held by the current session.
UNLOCK TABLES
implicitly releases any table locks held by the current session before acquiring new locks.
Another use for
UNLOCK TABLES
TABLES WITH READ LOCK
Section 13.7.6.2,
"FLUSH
system such as Veritas that can take snapshots in time.)
A table lock protects only against inappropriate reads or writes by other sessions. The session
holding the lock, even a read lock, can perform table-level operations such as
operations are not transaction-safe, so an error occurs if the session attempts one during an active
transaction or while holding a table lock.
The following discussion applies only to
ignored) for a
TEMPORARY
created, regardless of what other locking may be in effect. No lock is necessary because no other
session can see the table.
For information about other conditions on the use of
be used while
LOCK TABLES
Conditions"
Rules for Lock Acquisition
To acquire table locks within the current session, use the
types are available:
lock:
READ [LOCAL]
• The session that holds the lock can read the table (but not write it).
• Multiple sessions can acquire a
• Other sessions can read the table without explicitly acquiring a
• The
modifier enables nonconflicting
LOCAL
sessions to execute while the lock is held. (See
cannot be used if you are going to manipulate the database using processes external to the
LOCAL
server while you hold the lock. For
5.0.13. (Before that,
tables, the use of
InnoDB
does the same thing, and no locks are needed.)
[LOW_PRIORITY] WRITE
• The session that holds the lock can read and write the table.
• Only the session that holds the lock can access the table. No other session can access it until the
lock is released.
• Lock requests for the table by other sessions block while the
• The
LOW_PRIORITY
described later.
and
LOCK TABLES
UNLOCK TABLES
adds all base tables used in the view to the set of tables to be locked
is to release the global read lock acquired with the
statement, which enables you to lock all tables in all databases. See
Syntax". (This is a very convenient way to get backups if you have a file
non-TEMPORARY
table. The table can be accessed freely by the session within which it was
is in effect, see
lock for the table at the same time.
READ
InnoDB
essentially does nothing: It does not lock the table at all, so for
READ LOCAL
is deprecated because a plain consistent-read
READ LOCAL
lock:
modifier affects lock scheduling if the
1115
Syntax
LOCK TABLES
LOCK
Section 13.3.5.2,
"LOCK TABLES
tables.
LOCK TABLES
and statements that cannot
LOCK TABLES
Section 13.3.5.3, "Table-Locking Restrictions and
LOCK TABLES
READ
statements (concurrent inserts) by other
INSERT
Section 8.7.3, "Concurrent
tables,
is the same as
READ LOCAL
WRITE
WRITE
[577]
privilege, and
TABLES, any tables used in
and
Triggers".
LOCK TABLES
FLUSH
TABLE. Truncate
DROP
is permitted (but
statement. The following lock
lock.
Inserts".) However,
as of MySQL
READ
SELECT
lock is held.
lock request must wait, as
READ

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents