LOCK TABLES

LOCK TABLES table_name [AS alias_name] {READ | [LOW_PRIORITY] WRITE}
  [, table_name [AS alias_name] {READ | [LOW_PRIORITY] WRITE} ...]

Description: Obtains a lock on a table or tables given by table_name, for use by the current thread.

LOCK TABLES may have to wait for other threads to finish before locks on all tables are obtained, and MySQL operates a queuing system to manage the granting of READ and WRITE locks. When using this statement, you must lock all tables that will be used by the subsequent queries. Locks are released when the thread finishes, when another LOCK TABLES is issued, or when an UNLOCK TABLES is issued.

If a thread obtains a READ lock, that thread and all other threads can perform only read operations from those tables.

If a thread obtains a WRITE lock, it becomes the only thread with any access to those tables. It can read and write, but no other threads can access the tables.

Normally, MySQL grants a lock to a thread in the READ queue only when no threads are waiting to obtain a WRITE lock (thus giving WRITE locks a higher priority). LOW_PRIORITY WRITE makes the queuing system behave the opposite way, so that a WRITE lock has to wait until all pending READ locks are cleared from the queues before the WRITE lock is granted.

Description in: Day 17

See also: UNLOCK TABLES, SELECT...HIGH PRIORITY

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.162.65