包含多条sql语句要么都执行成功,要么都执行不成功
回到原来没执行的状态
create table user(
id int primary key auto_increment,
name char(32),
balance int
);
insert into user(name,balance)
values
(‘wsb‘,1000),
(‘egon‘,1000),
(‘ysb‘,1000);
start transaction;
update user set balance=900 where id=1;
update user set balance=1010 where id=2;
update user set balance=1090 where id=3;
commit; 写入MySQL,这样就真的不能回滚了
rollback; 如果没有commit, 那么执行这条语句就会回滚, 回到原来没执行的状态
原文:http://blog.51cto.com/13764714/2166194