Loading

InnoDB RR隔离级别下解决幻读

InnoDB RR隔离级别下解决幻读

演示

A B
begin; begin;
select *from award where id>2;
insert into award (id) values(6);
commit;
select *from award where id>2;
commit;

第一次select

id|award_id|award_type|award_name|award_content|create_time        |update_time        |
--+--------+----------+----------+-------------+-------------------+-------------------+
 3|3       |         1|ipad      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
 4|4       |         1|AirPods   |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
 5|5       |         1|Book      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|

第二次select

id|award_id|award_type|award_name|award_content|create_time        |update_time        |
--+--------+----------+----------+-------------+-------------------+-------------------+
 3|3       |         1|ipad      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
 4|4       |         1|AirPods   |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
 5|5       |         1|Book      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
A B
begin ; begin;
select *from award where id>2;
insert into award (id) values(6);
commit;
update award set award_type =2 where id = 6;
select *from award where id>2;
commit;

第一次select

id|award_id|award_type|award_name|award_content|create_time        |update_time        |
--+--------+----------+----------+-------------+-------------------+-------------------+
3|3       |         1|ipad      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
4|4       |         1|AirPods   |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|
5|5       |         1|Book      |Code         |2021-08-15 15:38:05|2021-08-15 15:38:05|

第二次select

id|award_id|award_type|award_name|award_content|create_time            |update_time            |
--+--------+----------+----------+-------------+-----------------------+-----------------------+
 3|3       |         1|ipad      |Code         |    2021-08-15 15:38:05|    2021-08-15 15:38:05|
 4|4       |         1|AirPods   |Code         |    2021-08-15 15:38:05|    2021-08-15 15:38:05|
 5|5       |         1|Book      |Code         |    2021-08-15 15:38:05|    2021-08-15 15:38:05|
 6|        |         2|          |             |2023-08-18 14:54:19.492|2023-08-18 14:54:19.492|

posted @ 2023-09-01 17:37  花园SON  阅读(10)  评论(0编辑  收藏  举报