In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Mysql transaction isolation level content (read submission) handout, hope to give you some knowledge to supplement and update, if there are other problems to understand, you can continue to pay attention to my update article in the industry information. Mysql transaction isolation level read commit
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
Let's take a look at the transaction isolation details under the current isolation level and open two query terminals A and B.
Below is an order table with initial data as follows
mysql> select * from `order`;+----+--------+| id | number |+----+--------+| 13 | 1 |+---+-------+1 row in set (0.00 sec) Step 1, open transaction mysql> start transaction in both A and B;Query OK, 0 rows affected (0.00 sec) Step 2 Query number value in both 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) Step 3 Change the number in B to 2, but do not commit 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) Found that the value in A was not modified. Step 5: Submit transaction B and query the value in A 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) Find that the value in A has changed Step 6: Commit the transaction in A and query the values of A and 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) Found that the values in A and B are changed to 2.
Here's a simple diagram
We can see that when the transaction isolation level is read committed, when the transaction in B commits, even if A does not commit, it can read the result of B's transaction commit. This solves the problem of dirty reading.
The above is the introduction of Mysql transaction isolation level content (read commit) details, more please pay attention to other related 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.