原来:
drop table if exists account;
create table account
(
name varchar(20),
money int
);
insert into account values('scy',1500),('sxr',1500);
show variables like 'autocommit';
set autocommit=0;
start transaction;
update account set money=0 where name ='scy';
update account set money=0 where name ='sxr';
rollback;
结果:
正确方法:
drop table if exists account;
create table account
(
name varchar(20),
money int
)engine=innodb;
insert into account values('scy',1500),('sxr',1500);
show variables like 'autocommit';
set autocommit=0;
start transaction;
update account set money=0 where name ='scy';
update account set money=0 where name ='sxr';
rollback;
结果: