create table shuzhi
(
id mediumint(8) primary key,
name varchar(30),
shuzhi mediumint(10)
);
alter table shuzhi engine=innodb;
insert into shuzhi values(1,'aa',1000);
insert into shuzhi values(2,'bb',2000);
insert into shuzhi values(3,'cc',3000);
insert into shuzhi values(4,'dd',4000);
insert into shuzhi values(5,'ee',5000);
insert into shuzhi values(6,'ff',6000);
insert into shuzhi values(7,'gg',7000);
insert into shuzhi values(8,'hh',8000);
开始测试事物的4种隔离级别 第一种:read uncommitted (读未提交)
设置隔离级别
#查询当前的隔离级别
select @@tx_isolation
#设置隔离级别 set session transaction isolation level [隔离级别]
set session transaction isolation level read uncommitted
先开启第一个进程 先开启事物 暂不进行查询
窗口1
start transaction;
再开启第二个进程(终端)
先开启事物 修改一条记录 不commit
窗口2
start transaction;
update shuzhi set shuzhi='8888' where id=7;
去数据库查询发现id=7的值还是7000值并没改变
再去窗口1中查询这个记录
窗口1
start transaction;
select * from shuzhi where id=7