首页 > 其他 > 详细

non-transactional tables

时间:2019-03-05 10:36:57      阅读:635      评论:0      收藏:0      [点我收藏+]

异常日志:

java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.


-----------
这是因为在5.6及以上的版本内,开启了enforce_gtid_consistency=true功能导致的,MySQL官方解释说当启用enforce_gtid_consistency功能的时候,MySQL只允许能够保障事务安全,并且能够被日志记录的SQL语句被执行,像create table … select 和 create temporarytable语句,以及同时更新事务表和非事务表的SQL语句或事务都不允许执行。

-----------

那么什么又是 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)
    
max_binlog_stmt_cache_size 该参数影响的是非事务表,如MyISAM,该参数不够时,则提示需要更多的空间。
max_binlog_cache_size 该参数影响的是事务表,如InnoDB,该参数不够时,则提示需要更多的空间。

non-transactional tables

原文:https://www.cnblogs.com/johnson0608/p/10475078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!