赞
踩
记录一下
mysql的默认隔离级别是可重复读。
默认情况下, MySQL启用自动提交模式(变量autocommit为ON)。这意味着, 只要你执行DML操作的语句,MySQL会立即隐式提交事务(Implicit Commit)。
Value的值为ON,表示autocommit开启。OFF表示autocommit关闭。
因为 autocommit 分为会话变量和全局变量, 所以在修改时要区分。
1.查看会话自动提交的状态
- mysql> show session variables like 'autocommit';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | autocommit | ON |
- +---------------+-------+
- 1 row in set, 1 warning (0.00 sec)
2.查看全局自动提交状态
- mysql> show global variables like 'autocommit';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | autocommit | ON |
- +---------------+-------+
- 1 row in set, 1 warning (0.00 sec)
3. 关闭会话变量的自动提交
- mysql> set session autocommit = 0;
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> show session variables like 'autocommit';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | autocommit | OFF |
- +---------------+-------+
- 1 row in set, 1 warning (0.00 sec)
4.打开会话变量的自动提交
- mysql> set session autocommit = 1;
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> show session variables like 'autocommit';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | autocommit | ON |
- +---------------+-------+
- 1 row in set, 1 warning (0.00 sec)
5.全局变量的操作和会话变量一致。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。