autocommit和start transaction

简介: 在存储过程中使用事务时,通常会显示设置事务自动提交为0 (set autocommit=0;)这里极有可能是个坑,在同一个连接中,事务执行完或存储过程执行完后,autocommit仍为0,如果后面没有commit语句则可能导致数据丢失;对应mysql官网,没有解释很清楚 set autocommit =0 和 start transaction,是否必须结合使用,但有一句是,s

在存储过程中使用事务时,通常会显示设置事务自动提交为0 (set autocommit=0;)这里极有可能是个坑,在同一个连接中,事务执行完或存储过程执行完后,autocommit仍为0,如果后面没有commit语句则可能导致数据丢失;对应mysql官网,没有解释很清楚 set autocommit =0 和 start transaction,是否必须结合使用,但有一句是,start transaction 有隐含的 设置autocommit为0 作用,原句为: To disable autocommit mode implicitly for a single series of statements, use the START TRANSACTION statement ,所以可以去掉set autocommit=0 ,如果非得使用时在commit和rollback 后,将 autocommit设置为1

目录
相关文章
|
5月前
The transaction associated with this command is not the connection‘s active
The transaction associated with this command is not the connection‘s active
64 0
|
2月前
|
SQL Oracle 关系型数据库
transaction
"transaction" 是一个计算机科学术语,通常指在计算机系统中执行的操作,以完成特定的任务或操作。在数据库系统中,"transaction" 是指一组操作,这些操作被设计为作为一个单元执行,以确保数据的一致性和完整性。
29 4
|
5月前
|
Java 关系型数据库 MySQL
定时任务Quzrtz:Failed to override connection auto commit/transaction isolation
定时任务Quzrtz:Failed to override connection auto commit/transaction isolation
|
6月前
|
SQL 关系型数据库 MySQL
【MySQL异常】MySQL事务锁问题----lock wait timeout exceeded; try restarting transaction
【MySQL异常】MySQL事务锁问题----lock wait timeout exceeded; try restarting transaction
49 0
|
11月前
|
关系型数据库 MySQL
|
消息中间件 缓存 Oracle
Transaction 1 |学习笔记
快速学习 Transaction 1
69 0
|
SQL 缓存 安全
Transaction 2 |学习笔记
快速学习 Transaction 2
101 0
Transaction 2 |学习笔记
|
SQL 数据库连接 C#