mysql_commit() COMMIT ROLLBACK 提交 回滚 连接释放
MySQL :: MySQL 8.0 Reference Manual :: 28.7.7.6 mysql_commit() https://dev.mysql.com/doc/refman/8.0/en/mysql-commit.html
bool mysql_commit(MYSQL *mysql)
Commits the current transaction.
The action of this function is subject to the value of the completion_type
system variable. In particular, if the value of completion_type
isRELEASE
(or 2), the server performs a release after terminating a transaction and closes the client connection. Call mysql_close()
from the client program to close the connection from the client side.
None.
MySQL :: MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_completion_type
Property | Value |
---|---|
Command-Line Format | --completion-type=# |
System Variable | completion_type |
Scope | Global, Session |
Dynamic | Yes |
SET_VAR Hint Applies |
No |
Type | Enumeration |
Default Value | NO_CHAIN |
Valid Values |
|
The transaction completion type. This variable can take the values shown in the following table. The variable can be assigned using either the name values or corresponding integer values.
Value | Description |
---|---|
NO_CHAIN (or 0) |
COMMIT and ROLLBACK are unaffected. This is the default value. |
CHAIN (or 1) |
COMMIT and ROLLBACK are equivalent to COMMIT AND CHAIN and ROLLBACK AND CHAIN , respectively. (A new transaction starts immediately with the same isolation level as the just-terminated transaction.) |
RELEASE (or 2) |
COMMIT and ROLLBACK are equivalent to COMMIT RELEASE and ROLLBACK RELEASE , respectively. (The server disconnects after terminating the transaction.) |
completion_type
affects transactions that begin with START TRANSACTION
or BEGIN
and end with COMMIT
or ROLLBACK
. It does not apply to implicit commits resulting from execution of the statements listed in Section 13.3.3, “Statements That Cause an Implicit Commit”. It also does not apply for XA COMMIT
, XA ROLLBACK
, or when autocommit=1
.
理解commit
13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Syntax
START TRANSACTION
[transaction_characteristic [, transaction_characteristic] ...]
transaction_characteristic: {
WITH CONSISTENT SNAPSHOT
| READ WRITE
| READ ONLY
}
BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET autocommit = {0 | 1}
These statements provide control over use of transactions:
-
START TRANSACTION
orBEGIN
start a new transaction. -
COMMIT
commits the current transaction, making its changes permanent. -
ROLLBACK
rolls back the current transaction, canceling its changes. -
SET autocommit
disables or enables the default autocommit mode for the current session.
MySQL :: MySQL 8.0 Reference Manual :: 13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Syntax https://dev.mysql.com/doc/refman/8.0/en/commit.html
【如果在select读的情况下,假如认为对数据库无影响无烙印的操作,那么commit提交,就没有必要】
【连接的关闭:分为客户端、mysql服务端,都可以发起关闭】
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2017-12-05 crontab -e 定时任务中的 脚本文件 路径
2017-12-05 无限次重启该脚本
2017-12-05 公司 怎么提问
2017-12-05 武汉哪里有卖篮球架的 n-gram
2017-12-05 eval
2017-12-05 接口(Interfaces)与反射(reflection) 如何利用字符串驱动不同的事件 动态地导入函数、模块
2017-12-05 compile java sources