首頁  >  文章  >  資料庫  >  MySQL 事務表與非事務表

MySQL 事務表與非事務表

黄舟
黄舟原創
2017-02-06 10:32:292172瀏覽

查看 max_binlog_stmt_cache_size 參數解釋時,有這麼一句話 If nontransactional statements within a transaction require more than this many bytes of memory, the server generates an error.

那麼,什麼是 non trans?

在 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)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn