|
14.2.10.9. Implicit Transaction Commit and Rollback
By default, MySQL begins each client connection with autocommit
mode enabled. When autocommit is enabled, MySQL does a commit
after each SQL statement if that statement did not return an
error. If an SQL statement returns an error, the commit or
rollback behavior depends on the error. See
Section 14.2.15, “InnoDB Error Handling”.
If you have the autocommit mode off and close a connection
without explicitly committing the final transaction, MySQL rolls
back that transaction.
Each of the following statements (and any synonyms for them)
implicitly end a transaction, as if you had done a
COMMIT before executing the statement:
ALTER FUNCTION , ALTER
PROCEDURE , ALTER TABLE ,
BEGIN , CREATE
DATABASE , CREATE FUNCTION ,
CREATE INDEX , CREATE
PROCEDURE , CREATE TABLE ,
DROP DATABASE , DROP
FUNCTION , DROP INDEX ,
DROP PROCEDURE , DROP
TABLE , LOAD MASTER DATA ,
LOCK TABLES , RENAME
TABLE , SET AUTOCOMMIT=1 ,
START TRANSACTION ,
TRUNCATE , UNLOCK
TABLES .
UNLOCK TABLES commits a transaction only
if any tables are currently locked.
The CREATE TABLE statement in
InnoDB is processed as a single
transaction. This means that a ROLLBACK
from the user does not undo CREATE TABLE
statements the user made during that transaction.
Transactions cannot be nested. This is a consequence of the
implicit COMMIT performed for any current
transaction when you issue a START
TRANSACTION statement or one of its synonyms.
|
|