34,588
社区成员
发帖
与我相关
我的任务
分享
create table tb(id int primary key,v varchar(20));
insert into tb(id,v)
select 1,'data1' union all
select 2,'data2' union all
select 3,'data3' union all
select 4,'data4';
/*
drop table tb;
*/
connection 1, session 1:
/*session 1*/
set autocommit=0;
set session transaction isolation level read uncommitted;
start transaction;
update tb set v=concat(v,'_new') where id>=3;
select * from tb where id>=3;
select @@tx_isolation;
connection 2,session 2:
/*session 2*/
set autocommit=0;
start transaction;
update tb set v=concat(v,'_o') where id>=4;
insert into tb(id,v) select 5,'data5';
select * from tb where id>=3;
select @@tx_isolation;
先执行session 1代码,再执行session2代码,
你会发现,session 2中,sql执行到update语句,会一直在等待状态。