The statements listed in this section (and any synonyms for them)
implicitly end any transaction active in the current session, as
if you had done a
executing the statement.
Most of these statements also cause an implicit commit after executing. The intent is to handle each such statement in its own special transaction. Transaction-control and locking statements are exceptions: If an implicit commit occurs before execution, another does not occur after.
Data definition language (DDL) statements that define or modify database objects.
CREATE SPATIAL REFERENCE SYSTEM,
DROP SPATIAL REFERENCE SYSTEM,
DROP TABLEstatements do not commit a transaction if the
TEMPORARYkeyword is used. (This does not apply to other operations on temporary tables such as
CREATE INDEX, which do cause a commit.) However, although no implicit commit occurs, neither can the statement be rolled back, which means that the use of such statements causes transactional atomicity to be violated. For example, if you use
CREATE TEMPORARY TABLEand then roll back the transaction, the table remains in existence.
CREATE TABLEstatement in
InnoDBis processed as a single transaction. This means that a
ROLLBACKfrom the user does not undo
CREATE TABLEstatements the user made during that transaction.
CREATE TABLE ... SELECTcauses an implicit commit before and after the statement is executed when you are creating nontemporary tables. (No commit occurs for
CREATE TEMPORARY TABLE ... SELECT.)
Statements that implicitly use or modify tables in the
Transaction-control and locking statements.
SET autocommit = 1(if the value is not already 1),
UNLOCK TABLEScommits a transaction only if any tables currently have been locked with
LOCK TABLESto acquire nontransactional table locks. A commit does not occur for
FLUSH TABLES WITH READ LOCKbecause the latter statement does not acquire table-level locks.
Transactions cannot be nested. This is a consequence of the implicit commit performed for any current transaction when you issue a
START TRANSACTIONstatement or one of its synonyms.
Statements that cause an implicit commit cannot be used in an XA transaction while the transaction is in an
BEGINstatement differs from the use of the
BEGINkeyword that starts a
BEGIN ... ENDcompound statement. The latter does not cause an implicit commit. See Section 13.6.1, “BEGIN ... END Compound Statement”.
Data loading statements.
LOAD DATAcauses an implicit commit only for tables using the
LOAD INDEX INTO CACHE,
Replication control statements.
CHANGE REPLICATION SOURCE TO,
CHANGE MASTER TO. The SLAVE keyword was replaced with REPLICA in MySQL 8.0.22.