在ALTER TABLE之后,MySQL shell中的回滚不起作用

时间:2012-11-18 10:06:36

标签: mysql innodb

(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)

1 个答案:

答案 0 :(得分:9)

DDL在MySQL中不是事务性的。

任何DDL语句都会隐式提交open transaction。

手册中的更多详细信息:http://dev.mysql.com/doc/refman/5.5/en/implicit-commit.html