MySQL事务、提交、回滚 语法 START TRANSACTION [transaction_characteristic [, transaction_characteristic] ...] transaction_characteristic: { WITH CONSISTENT SNAPSHOT | READ WRITE | READ ONLY } BEGIN [WORK] COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE] ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE] SET autocommit = {0 | 1} 示例 SHOW VARIABLES LIKE 'autocommit'; SET autocommit = 0; START TRANSACTION; SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summary=@A WHERE type=1; -- either COMMIT or ROLLBACK COMMIT; ROLLBACK; SET autocommit = 1; 链接 https://dev.mysql.com/doc/refman/5.7/en/commit.html