mysql嵌套事务的问题
2016-01-21 13:45
585 查看
今天跟同事在讨论一段代码,我建议使用嵌套事务解决。当场用mysql示范,结果发现了以下问题
这时候另一个链接中会看到value=1.
查了资料:
在官方文档的隐式提交这一节https://dev.mysql.com/doc/refman/5.6/en/implicit-commit.html
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或者类似的操作时,任何当前事务都会被隐式的提交。
</pre><p><pre name="code" class="html">insert into table1 values('abc',0); set autocommit=0; start transaction; update table1 set value=1; start transaction;
这时候另一个链接中会看到value=1.
查了资料:
在官方文档的隐式提交这一节https://dev.mysql.com/doc/refman/5.6/en/implicit-commit.html
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或者类似的操作时,任何当前事务都会被隐式的提交。
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复