部分回滚
-- 格式化 TRUNCATE demo_transaction; -- 开启事务 BEGIN; -- 插入一条数据 INSERT INTO `demo_transaction`(id) VALUES(1); -- 开启 SAVEPOINT SAVEPOINT t1; INSERT INTO `demo_transaction`(id) VALUES(2); -- 回滚 SAVEPOINT ROLLBACK TO SAVEPOINT t1; -- 提交事务 COMMIT;
全部提交
-- 格式化 TRUNCATE demo_transaction; -- 开启事务 BEGIN; -- 插入一条数据 INSERT INTO `demo_transaction`(id) VALUES(1); -- 开启 SAVEPOINT SAVEPOINT t1; INSERT INTO `demo_transaction`(id) VALUES(2); -- 释放 SAVEPOINT RELEASE SAVEPOINT t1; -- 提交事务 COMMIT;
全部回滚
-- 格式化 TRUNCATE demo_transaction; -- 开启事务 BEGIN; -- 插入一条数据 INSERT INTO `demo_transaction`(id) VALUES(1); -- 开启 SAVEPOINT SAVEPOINT t1; INSERT INTO `demo_transaction`(id) VALUES(2); -- 释放 SAVEPOINT RELEASE SAVEPOINT t1; -- 提交事务 ROLLBACK;
标签:INSERT,事务,transaction,--,demo,SAVEPOINT,嵌套,Mysql,id From: https://www.cnblogs.com/wzf-Learning/p/16806264.html