The various kinds of FLUSH TABLES with READ lock and lock TABLES

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.