隐式提交的语句
事务控制语句和锁语句也有例外:如果一个隐式提交发生在执行之前,那么其他的在之后也不会发生。
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 FUNCTION
andDROP FUNCTION
also cause an implicit commit when used with stored functions, but not with user-defined functions. (ALTER FUNCTION
can only be used with stored functions.)CREATE TABLE
andDROP TABLE
statements do not commit a transaction if theTEMPORARY
keyword is used. (This does not apply to other operations on temporary tables such asALTER TABLE
andCREATE 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 TABLE
and then roll back the transaction, the table remains in existence.The
CREATE TABLE
statement inInnoDB
is processed as a single transaction. This means that aROLLBACK
from the user does not undoCREATE TABLE
statements the user made during that transaction.CREATE TABLE ... SELECT
causes 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
mysql
database.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 TABLES
commits a transaction only if any tables currently have been locked withLOCK TABLES
to acquire nontransactional table locks. A commit does not occur forUNLOCK TABLES
followingFLUSH TABLES WITH READ LOCK
because 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 TRANSACTION
statement or one of its synonyms.Statements that cause an implicit commit cannot be used in an XA transaction while the transaction is in an
ACTIVE
state.The
BEGIN
statement differs from the use of theBEGIN
keyword that starts aBEGIN ... END
compound statement. The latter does not cause an implicit commit. See Section 13.6.1, “BEGIN ... END Compound Statement”. -
Data loading statements.
LOAD DATA
.LOAD DATA
causes an implicit commit only for tables using theNDB
storage 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
.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了