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 本节中列出的语句(以及它们的任何同义词)隐式结束当前会话中活动的任何事务,就像您在执行该语句之前执行了COMMIT
before executing the statement.COMMIT
一样。
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.定义或修改数据库对象的数据定义语言(DDL)语句。 ALTER EVENT
, ALTER FUNCTION
, ALTER PROCEDURE
, ALTER SERVER
, ALTER TABLE
, ALTER VIEW
, CREATE DATABASE
, CREATE EVENT
, CREATE FUNCTION
, CREATE INDEX
, CREATE PROCEDURE
, CREATE ROLE
, CREATE SERVER
, CREATE SPATIAL REFERENCE SYSTEM
, CREATE TABLE
, CREATE TRIGGER
, CREATE VIEW
, DROP DATABASE
, DROP EVENT
, DROP FUNCTION
, DROP INDEX
, DROP PROCEDURE
, DROP ROLE
, DROP SERVER
, DROP SPATIAL REFERENCE SYSTEM
, DROP TABLE
, DROP TRIGGER
, DROP VIEW
, INSTALL PLUGIN
, RENAME TABLE
, TRUNCATE TABLE
, UNINSTALL PLUGIN
.
如果使用CREATE TABLE
and DROP TABLE
statements do not commit a transaction if the TEMPORARY
keyword is used. TEMPORARY
关键字,CREATE TABLE
和DROP TABLE
语句不会提交事务。(This does not apply to other operations on temporary tables such as (这不适用于临时表上的其他操作,如ALTER TABLE
and CREATE INDEX
, which do cause a commit.) ALTER TABLE
和CREATE INDEX
,它们确实会导致提交。)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 TABLE
and then roll back the transaction, the table remains in existence.CREATE TEMPORARY TABLE
,然后回滚事务,则该表仍然存在。
The CREATE TABLE
statement in InnoDB
is processed as a single transaction. InnoDB
中的CREATE TABLE
语句作为单个事务处理。This means that a 这意味着用户的ROLLBACK
from the user does not undo CREATE TABLE
statements the user made during that transaction.ROLLBACK
不会撤消用户在该事务期间所做的CREATE TABLE
语句。
创建非临时表时,CREATE TABLE ... SELECT
causes an implicit commit before and after the statement is executed when you are creating nontemporary tables. CREATE TABLE ... SELECT
会在执行语句之前和之后导致隐式提交。(No commit occurs for (CREATE TEMPORARY TABLE ... SELECT
.)CREATE TEMPORARY TABLE ... SELECT
不发生提交。)
Statements that implicitly use or modify tables in the 隐式使用或修改mysql
database.mysql
数据库中的表的语句。 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), (如果该值不是1),START TRANSACTION
, UNLOCK TABLES
.
UNLOCK TABLES
commits a transaction only if any tables currently have been locked with LOCK TABLES
to acquire nontransactional table locks. UNLOCK TABLES
仅在当前任何表被LOCK TABLES
锁定以获取非事务性表锁的情况下提交事务。A commit does not occur for UNLOCK TABLES
following FLUSH TABLES WITH READ LOCK
because the latter statement does not acquire table-level locks.FLUSH TABLES WITH READ LOCK
之后的UNLOCK TABLES
不会发生提交,因为后一条语句没有获得表级锁。
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.START TRANSACTION
语句或其同义词之一时对任何当前事务执行隐式提交的结果。
Statements that cause an implicit commit cannot be used in an XA transaction while the transaction is in an 当XA事务处于ACTIVE
state.ACTIVE
状态时,不能在该事务中使用导致隐式提交的语句。
The BEGIN
statement differs from the use of the BEGIN
keyword that starts a BEGIN ... END
compound statement. BEGIN
语句不同于使用BEGIN
关键字启动BEGIN ... END
复合语句。The latter does not cause an implicit commit. 后者不会导致隐式提交。See Section 13.6.1, “BEGIN ... END Compound Statement”.请参阅第13.6.1节,“BEGIN ... END复合语句”。
Data loading statements.数据加载语句。 LOAD DATA
. LOAD DATA
causes an implicit commit only for tables using the NDB
storage engine.LOAD DATA
只会导致使用NDB
存储引擎的表的隐式提交。
Administrative statements.管理语句。 ANALYZE TABLE
, CACHE INDEX
, CHECK TABLE
, FLUSH
, LOAD INDEX INTO CACHE
, OPTIMIZE TABLE
, REPAIR TABLE
, RESET
(but not RESET PERSIST
).
Replication control statements复制控制语句. START REPLICA | SLAVE
, STOP REPLICA | SLAVE
, RESET REPLICA | SLAVE
, CHANGE REPLICATION SOURCE TO
, CHANGE MASTER TO
.