5

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

1 回答 1

10

DDL 在 MySQL 中不是事务性的。

任何 DDL 语句都会隐式提交打开的事务。

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

于 2012-11-18T10:07:51.393 回答