手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL事务表和非事务表

[日期:2016-09-17] 来源:Linux社区  作者:QQ:463725310 [字体:大 中 小]

MySQL事务表和非事务表

查看 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存储引擎的表。
非事务表的特点是不支持回滚,看下面的列子
>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的表,支持回滚操作。
>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,该参数不够时,则提示需要更多的空间。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-09/135236.htm

linux
相关资讯       MySQL事务表  MySQL非事务表 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款