Difference between select for update and lock in share mode for Row-level locks in MySQL

Source: Internet
Author: User

Record it by yourself to make a better impression. The English documents are from the official MySQL documents. The Chinese is translated by yourself according to your understanding.

Select... lock in share mode sets a Shared Mode Lock on the rows
Read. A Shared Mode Lock enables other sessions to read the rows
Not to modify them. The rows read are the latest available, so if they
Belong to another transaction that has not yet committed, the read
Blocks until that transaction ends.

Set a share mode lock on the read row. This shared lock allows other sessions to read data but cannot be modified. The row reads the latest data. If it is used by other transactions but not committed, the read lock will be blocked and the transaction ends.

Select... for update sets an exclusive lock on the rows
Read. An exclusive lock prevents other sessions from accessing the rows
For reading or writing.

Set an exclusive lock on the read row. Organize other sessions to read or write row data

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.