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 ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.