(MySQL 5.5,InnoDB表)为什么我不能回滚到保存点或以前的begin
语句?
mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql> savepoint id;
Query OK, 0 rows affected (0.00 sec)
mysql> alter table sg_Section add column (published tinyint(1) default 0);
Query OK, 2 rows affected (0.30 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> rollback to savepoint id;
ERROR 1305 (42000): SAVEPOINT id does not exist
如果在保存点之后没有运行任何命令,它似乎“工作”:
mysql> savepoint id;
Query OK, 0 rows affected (0.00 sec)
mysql> rollback to savepoint id;
Query OK, 0 rows affected (0.00 sec)
答案 0 :(得分:9)
DDL在MySQL中不是事务性的。
任何DDL语句都会隐式提交open transaction。
手册中的更多详细信息:http://dev.mysql.com/doc/refman/5.5/en/implicit-commit.html