事务/数据库操作之事务,开启回滚提交
#事务:一组操作,要么全成功要么全失败
1开启事务:strat transaction
2回滚事务,即撤销指定sql语句(只有insert /delete /update):rollback
3提交事务 提交未存储事务:commit
保留点,事务处理中设置的点:savepoint
1start transaction
执行sql语句,
update 表 set 字段=‘神马’ where id =神马
2 rollback(撤销sql语句只有delete,update,insert),可以查看原表
删除sql
3 保存提交事务 commit
4 设置保存点
delete from test2 where id=4;
savepoint delete1;
select * from test2;
delete from test2 where id=1;
savepoint delete2;
select * from test2;
rollback to delete1;
select * from test2;