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,該參數不夠時,則提示需要更多的空間。

以上就是MySQL 事務表和非事務表的內容,更多相關內容請關注PHP中文網(www.php.cn)!

? 版權聲明
THE END
喜歡就支持一下吧
點贊10 分享