1.创建一个数据库
create table account(
-> id int primary key auto_increment,
-> name varchar(40),
-> money float
-> );
insert into account(name,money) values
-> ('a',1000),
-> ('b',1000);
2.事务的提交
start transaction;
update account set money=money-100 where name='a';
update account set money=money+100 where name='b';
commit;/
3.
update account set money=money+100 where name='a';
update account set money=money-100 where name='b';
4.
5.
update account set money=money+100 where name='a';
update account set money=money-100 where name='b';
commit;
update account set money=money-100 where name='a';
update account set money=money+100 where name='b';
rollback;
set session transaction isolation level read uncommitted;
select @@transaction_isolation;
start transaction;
select * from account;
update account set money=money-100 where name='a';
update account set money=money+100 where name='b';
set session transaction isolation level read committed;
start transaction;
select * from account;
start transaction;
update account set money=money-100 where name='a';
update account set money=money+100 where name='b';
start transaction;
select * from account;
update account set money=money-100 where name='a';