1.FLUSH TABLES with READ LOCK
This command is a global read lock, and all of the library tables are locked for read-only after the command has been executed. is generally used in the database online backup, this time the database write operations will be blocked, read operation smoothly.
The unlocked statement is also unlock tables.
2.LOCK TABLES tbl_name [as alias] {READ [LOCAL] | [Low_priority] WRITE}
This command is a table-level lock that can be customized to lock a table. Example: Lock tables test read; Does not affect write operations on other tables.
The unlock statement is also unlock tables.
Both statements need to be aware of the characteristics when executing, that is, implicitly committed statements. The unlock tables is implicitly executed when exiting the MySQL terminal. That is, if you want the table lock to take effect, you must always keep the conversation.
P.S. MySQL's read lock and Wirte lock
Read-lock: Allows other concurrent read requests, but blocks write requests, which can be read at the same time, but no write is allowed. Also called shared lock
Write-lock: Does not allow other concurrent read and write requests, is exclusive (exclusive). Also called exclusive lock
The various kinds of FLUSH TABLES with READ lock and lock TABLES