Mysql lock read

Source: Internet
Author: User

Mysql lock read
Locking Reads

In the same transaction, if you query data first and then insert or modify the relevant data, the standard SLELECT will not provide sufficient protection. During your query, another transaction can update or delete the same row. InnoDB provides two types of lock reads:

  • SELECT... LOCK IN SHARE MODE

Add a shared lock to each row. Other sessions can also read these rows, but they cannot be modified until your transaction is committed. If these rows have been modified by other transactions but have not yet been committed, your query must wait until the transaction ends.

  • SELECT... FOR UPDATE

For none of the retrieved index records, lock these rows and the associated index records

 

In fact, the former is an intention-sharing lock, and the latter is an intention-exclusive lock.

 

Related Article

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.