设为首页 加入收藏

TOP

MySQL事务学习-->隔离级别(二)
2015-07-24 11:53:01 来源: 作者: 【 】 浏览:15
Tags:MySQL 事务 学习 --> 隔离 级别
l> create table a (b int, primary key (b)) engine=innodb; ERROR 1050 (42S01): Table 'a' already exists mysql> select @@tx_isolation; +----------------+ | @@tx_isolation | +----------------+ | READ-COMMITTED | +----------------+ 1 row in set (0.00 sec) mysql> begin -> ; Query OK, 0 rows affected (0.00 sec) mysql> insert into a select 100000; ERROR 1665 (HY000): Cannotexecute statement: impossible to write to binary log since BINLOG_FORMAT =STATEMENT and at least one table uses a storage engine limited to row-basedlogging. InnoDB is limited to row-logging when transaction isolation level isREAD COMMITTED or READ UNCOMMITTED. ERROR 1665 (HY000): Cannotexecute statement: impossible to write to binary log since BINLOG_FORMAT =STATEMENT and at least one table uses a storage engine limited to row-basedlogging. InnoDB is limited to row-logging when transaction isolation level isREAD COMMITTED or READ UNCOMMITTED. [Note]:在mysql5.1以及mysql5.6模式下实验过都是如此。也许可以知道通过将innodb_locks_unsafe_for_binlog设置为1,来可以使binlog日志在statement下使用readcommitted的事务隔离级别: [sql] mysql> select @@innodb_locks_unsafe_for_binlog; +----------------------------------+ | @@innodb_locks_unsafe_for_binlog | +----------------------------------+ | 0 | +----------------------------------+ 1 row in set (0.00 sec) mysql> set global innodb_locks_unsafe_for_binlog=1; ERROR 1238 (HY000): Variable 'innodb_locks_unsafe_for_binlog' is a readonly variable mysql> 此参数是只读模式,需要修改my.cnf重新启动才行。 在my.cnf里面的[mysqld]添加 [mysqld] innodb_locks_unsafe_for_binlog = 1 然后重启,然后去check模仿一个事务操作,如下所示: [sql] mysql> select @@innodb_locks_unsafe_for_binlog; +----------------------------------+ | @@innodb_locks_unsafe_for_binlog | +----------------------------------+ | 1 | +----------------------------------+ 1 row in set (0.00 sec) mysql> mysql> use test; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select @@tx_isolation; +----------------+ | @@tx_isolation | +----------------+ | READ-COMMITTED | +----------------+ 1 row in set (0.00 sec) mysql> begin; Query OK, 0 rows affected (0.00 sec) mysql> insert into t select 15; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> select * from t; +--------+ | id | +--------+ | 1 | | 12 | | 15 | | 11111 | | 111110 | +--------+ 5 rows in set (0.00 sec)

?


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇mysql中的触发器和事务的操作 下一篇"oracle Universal Installe..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·HTTP协议深度解析: (2025-12-25 16:21:03)
·HTTP 概述 - MDN (2025-12-25 16:21:00)
·视频直播为什么要用u (2025-12-25 16:20:57)
·用 Python 进行数据 (2025-12-25 15:49:09)
·如何学习Python数据 (2025-12-25 15:49:07)