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

How mysql modifies transaction isolation level

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Editor to share with you how to modify the transaction isolation level of mysql, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Users can use SET TRANSACTION statements to change the isolation level for a single session or for all new connections. Its syntax is as follows:

SET [SESSION | GLOBAL] TRANSACTION ISOLATION LEVEL {READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE}

Note: the default behavior (without session and global) is to set the isolation level for the next (not started) transaction. If you use the GLOBAL keyword, the statement sets the default transaction level globally for all new connections created from that point (except for those that do not exist). You need SUPER permission to do this. Use the SESSION keyword to set the default transaction level for future transactions executed on the current connection. Any client is free to change the session isolation level (even in the middle of the transaction) or set the isolation level for the next transaction. Mysql > set tx_isolation='read-committed'

Query OK, 0 rows affected (0.00 sec)

+-+

| | @ @ tx_isolation |

+-+

| | READ-COMMITTED |

+-+

1 row in set (0.00 sec)

Mysql > select @ @ session.tx_isolation

+-- +

| | @ @ session.tx_isolation |

+-- +

| | READ-COMMITTED |

+-- +

1 row in set (0.00 sec)

Transaction isolation has changed.

There are still people on the Internet who write the set @ @ tx_isolation command, but this command is problematic.

Mysql > set @ @ tx_isolation='read-committed'

Query OK, 0 rows affected (0.00 sec)

Mysql > select @ @ session.tx_isolation

+-- +

| | @ @ session.tx_isolation |

+-- +

| | REPEATABLE-READ |

+-- +

1 row in set (0.00 sec)

Mysql > select @ @ tx_isolation

+-+

| | @ @ tx_isolation |

+-+

| | REPEATABLE-READ |

+-+

1 row in set (0.00 sec)

The isolation level of session things has not changed.

These are all the contents of the article "how mysql modifies transaction isolation levels". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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