In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you the "Mysql transaction isolation level reading submission example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "Mysql transaction isolation level reading submission sample analysis" this article.
View mysql transaction isolation levels
Mysql > show variables like'% isolation%' +-+-+ | Variable_name | Value | +-+-+ | tx_isolation | READ-COMMITTED | +-+-+ 1 row in set (0.00 sec)
You can see that the current transaction isolation level is READ-COMMITTED read commit
Let's take a look at the transaction isolation details under the current isolation level, and open the two query terminals An and B.
There is an order table below, with the initial data as follows
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 1 | +-+-+ 1 row in set (0.00 sec)
The first step is to start the transaction in A _ memory B.
Mysql > start transaction;Query OK, 0 rows affected (0.00 sec)
The second step is to query the number values in the two terminals.
A
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 1 | +-+-+ 1 row in set (0.00 sec)
B
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 1 | +-+-+ 1 row in set (0.00 sec)
The third step is to change the number in B to 2 without committing the transaction.
Mysql > update `order` set number=2;Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
Step 4 query the value in A
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 1 | +-+-+ 1 row in set (0.00 sec)
It is found that the value in A has not been changed.
Step 5, commit transaction B and query the value in An again
B
Mysql > commit;Query OK, 0 rows affected (0.01 sec)
A
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 2 | +-+-+ 1 row in set (0.00 sec)
Found that the value in A has changed
The sixth step is to commit the transaction in An and query the value of Amemery B again.
A
Mysql > commit;Query OK, 0 rows affected (0.00 sec) mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 2 | +-+ 1 row in set (0.00 sec)
B
Mysql > select * from `order`; +-+-+ | id | number | +-+-+ | 13 | 2 | +-+-+ 1 row in set (0.00 sec)
It is found that the values in APermine B have been changed to 2.
Here is a simple schematic diagram
We can see that when the transaction isolation level is read committed, when the transaction in B is committed, the result of the B transaction commit can be read even if An is not committed. This solves the problem of dirty reading.
The above is all the content of the article "sample Analysis of read commit for Mysql transaction isolation level". 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.