前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >MySQL事务表和非事务表

MySQL事务表和非事务表

作者头像
全栈程序员站长
发布2022-07-11 11:39:13
发布2022-07-11 11:39:13
2.3K0
举报

大家好,又见面了,我是全栈君。

查看 max_binlog_stmt_cache_size 参数解释时,有这么一句话 If nontransactional statements within a transaction require more than this many bytes of memory, the server generates an error.

那么,什么是 nontransactional statements ? 在 http://dev.mysql.com/ 查找 nontransactional关键字,查询结果第一个是 Rollback Failure for Nontransactional Tables

那么什么又是 Nontransactional Tables ?、

一、非事务表 Nontransactional Tables,非事务表,不支持事务的表,也就是使用MyISAM存储引擎的表。 非事务表的特点是不支持回滚,看下面的列子

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

>create table no_trans(id int) ENGINE=MyiSAM; >start transaction; >insert into no_trans values(1); >select * from no_trans; +———+ | id | +———+ | 1 | +———+ 1 row in set (0.00 sec) >rollback; Query OK, 0 rows affected, 1 warning (0.00 sec) >show warnings; +————–+———+———————————————————————————————–+ | Level | Code | Message | +————–+———+———————————————————————————————–+ | Warning | 1196 | Some non–transactional changed tables couldn’t be rolled back | +————–+———+———————————————————————————————–+ 1 row in set (0.00 sec) >select * from no_trans; +———+ | id | +———+ | 1 | +———+ 1 row in set (0.00 sec)

可以看到,非事务表回滚抛出警告,显示非事务表不支持回滚。

二、事务表 与非事务表对象的是事务表,比如使用InnoDB的表,支持回滚操作。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

>create table trans(id int); >start transaction; >insert into trans values(1); >select * from trans; +———+ | id | +———+ | 1 | +———+ 1 row in set (0.00 sec) >rollback; Query OK, 0 rows affected (0.00 sec) >select * from trans; Empty set (0.00 sec)

可以得出,nontransactional statements的意思是操作非事务表的语句。

三、相关参数 max_binlog_stmt_cache_size 该参数影响的是非事务表,如MyISAM,该参数不够时,则提示需要更多的空间。 max_binlog_cache_size 该参数影响的是事务表,如InnoDB,该参数不够时,则提示需要更多的空间。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/112132.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年2月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档