Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of mysql gap lock

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

mysql gap lock usage is what, for this problem, this article details the corresponding analysis and solution, hoping to help more want to solve this problem of small partners to find a simpler and easier way.

Interval lock, lock only one index interval (open interval, excluding double-ended endpoints)

Lock in gaps between index records, or before or after index records, excluding index records themselves.

Gap locks can be used to prevent phantom reads to ensure that no data is inserted between indexes.

examples

session 1:start transaction ; select * from news where number=4 for update ; session 2:start transaction ;insert into news value(2,4);#(blocking) insert into news value(2,2);#(blocking) insert into news value(4,4);#(blocking) insert into news value (4,5);#(blocking) insert into news value(7,5);#(successful execution) insert into news value(9,5);#(successful execution) insert into news value(11,5);#(successful execution) The answer to the question about the usage of mysql gap lock is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts, you can pay attention to the industry information channel for more relevant knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report