隐式提交的语句
事务控制语句和锁语句也有例外:如果一个隐式提交发生在执行之前,那么其他的在之后也不会发生。
Data definition language (DDL) statements that define or modify database objects. ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME, ALTER EVENT, ALTER PROCEDURE, ALTER SERVER, ALTER TABLE, ALTER VIEW, CREATE DATABASE, CREATE EVENT, CREATE INDEX, CREATE PROCEDURE, CREATE SERVER, CREATE TABLE, CREATE TRIGGER, CREATE VIEW, DROP DATABASE, DROP EVENT, DROP INDEX, DROP PROCEDURE, DROP SERVER, DROP TABLE, DROP TRIGGER, DROP VIEW, INSTALL PLUGIN, RENAME TABLE, TRUNCATE TABLE, UNINSTALL PLUGIN.
-
ALTER FUNCTION,CREATE FUNCTIONandDROP FUNCTIONalso cause an implicit commit when used with stored functions, but not with user-defined functions. (ALTER FUNCTIONcan only be used with stored functions.)CREATE TABLEandDROP TABLEstatements do not commit a transaction if theTEMPORARYkeyword is used. (This does not apply to other operations on temporary tables such asALTER TABLEandCREATE 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 useCREATE TEMPORARY TABLEand then roll back the transaction, the table remains in existence.The
CREATE TABLEstatement inInnoDBis processed as a single transaction. This means that aROLLBACKfrom the user does not undoCREATE 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 forCREATE TEMPORARY TABLE ... SELECT.) -
Statements that implicitly use or modify tables in the
mysqldatabase.ALTER USER,CREATE USER,DROP USER,GRANT,RENAME USER,REVOKE,SET PASSWORD. -
Transaction-control and locking statements.
BEGIN,LOCK TABLES,SET autocommit = 1(if the value is not already 1),START TRANSACTION,UNLOCK TABLES.UNLOCK TABLEScommits a transaction only if any tables currently have been locked withLOCK TABLESto acquire nontransactional table locks. A commit does not occur forUNLOCK TABLESfollowingFLUSH 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
ACTIVEstate.The
BEGINstatement differs from the use of theBEGINkeyword that starts aBEGIN ... ENDcompound statement. The latter does not cause an implicit commit. See Section 13.6.1, “BEGIN ... END Compound Statement”. -
Data loading statements.
LOAD DATA.LOAD DATAcauses an implicit commit only for tables using theNDBstorage engine. -
Administrative statements.
ANALYZE TABLE,CACHE INDEX,CHECK TABLE,FLUSH,LOAD INDEX INTO CACHE,OPTIMIZE TABLE,REPAIR TABLE,RESET. -
Replication control statements.
START SLAVE,STOP SLAVE,RESET SLAVE,CHANGE MASTER TO.

浙公网安备 33010602011771号