① start transaction;
① commit;
① rollback;
① create database chapter6;
② use chapter6;
③ create table account (
id int primary key auto_increment,
name varchar(40),
money float
);
④ insert into account (name,money) values("a",1000);
⑤ insert into account (name,money) values("b",1000);
① select * from account;
① start transaction;
② update account set money=money-100 where name="a";
③ update account set money=money+100 where name="b";
④ commit;
① select * from account;
① start transaction;
② update account set money=money+100 where name="a";
③ update account set money=money-100 where name="b";
① select * from account;
① \q
② use chapter6;
③ select * from account;
① start transaction;
② update account set money=money+100 where name="a";
③ update account set money=money-100 where name="b";
④ commit;
① select * from account;
① start transaction;
② update account set money=money-100 where name="a";
③ update account set money=money+100 where name="b";
① select * from account;
① rollback;
① select * from account;
① set session transaction isolation level read uncommitted;
① select @@transaction_isolation;
① 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";
① select * from account;
① 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";
① select * from account;
① start transaction;
② select * from account;
① update account set money=money-100 where name="a";
① update account set money=money-100 where name="a";
① select * from account;
① select * from account;
① set session transaction isolation level repeatable read;
① start transaction;
② select * from account;
① update account set money=money-100 where name="a";
① select * from account;
① select * from account;
① set session transaction isolation level read committed;
① start transaction;
② select * from account;
① select * from account;
① insert into account (name,money) values ("c",1000);
① select * from account;
① set session transaction isolation level repeatable read;
① start transaction;
② select * from account;
① select * from account;
① insert into account (name,money) values ("d",1000);
① select * from account;
① select * from account;
① set session transaction isolation level serializable;
① start transaction;
② select * from account;
① start transaction;
② insert into account (name,money) values ("e",1000);
① commit;