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

Introduction of exclusive Lock x and shared Lock s in mysql

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "the introduction of exclusive lock x and shared lock s in mysql". In daily operation, I believe that many people have doubts about the introduction of exclusive lock x and shared lock s in mysql. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "introduction of exclusive lock x and shared lock s in mysql". Next, please follow the editor to study!

First of all, the exclusive lock sharing lock must have a premise that the transaction is open.

It all happens in the course of a transaction.

# lock in share mode is required for sharing lock

Select * from table where .lock in share mode

# consistent unlocked read

Select * from table where.

# exclusive lock

Update, insert, delete automatically add exclusive locks

Select * from table_name where .for update

Give an example

Shared lock compatible shared lock

Figure 1

Figure 2

Figure 1 opens the s lock. Figure 2 can also use shared locks. This means that the s lock is a compatible shared lock.

Give an example

Exclusive lock incompatible shared lock exclusive lock

Figure 1. Other locks x locks.

Fig. 2 shared lock s lock is incompatible at this time because there is an x lock in figure 1

Figure 3. Other locks x locks are not compatible.

Conclusion s lock and s lock are compatible with each other. X lock and (x lock, s lock) are not compatible with each other.

At this point, the study on "introduction to exclusive lock x and shared lock s in mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Database

Wechat

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

12
Report