MySQL系统变量(systemvariables)(二)

2015-07-24 10:43:59 · 作者: · 浏览: 8
------+----------------+ | tx_isolation | READ-COMMITTED | +---------------+----------------+ --在root会话中我可以看到全局的值已经变为SERIALIZABLE root@localhost[(none)]> show global variables like '%isolation%'; +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | tx_isolation | SERIALIZABLE | +---------------+--------------+ --在fred中全局的也变成了SERIALIZABLE fred@localhost[(none)]> show global variables like '%isolation%'; +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | tx_isolation | SERIALIZABLE | +---------------+--------------+ --从上面的演示来说,无论global级别如何设置,不会影响到当前session级别的设置 --下面我们使用一个新用户登录来看看全局设置是否影响新会话 robin@SZDB:~> mysql -urobin --如下查询新会话的隔离级别等于全局的隔离级别 robin@localhost[(none)]> show variables like '%isolation%'; +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | tx_isolation | SERIALIZABLE | +---------------+--------------+ 4、如何获取变量值
除了通过前面演示的使用show global|session variables like 'vari_name'方式之外,我们可以通过查询
information_schema数据中特定的表来获得这些变量的值。
通过查询数据information_schema的表global_variables

root@localhost[information_schema]> select variable_value from global_variables where 
    -> variable_name='tx_isolation';
+----------------+
| variable_value |
+----------------+
| SERIALIZABLE   |
+----------------+

--Author: Leshami
--Blog  : http://blog.csdn.net/leshami

root@localhost[information_schema]> select @@global.tx_isolation;
+-----------------------+
| @@global.tx_isolation |
+-----------------------+
| SERIALIZABLE          |
+-----------------------+

root@localhost[information_schema]> select @@session.tx_isolation;
+------------------------+
| @@session.tx_isolation |
+------------------------+
| READ-COMMITTED         |
+------------------------+

--下面查询session_variables结果与查询global_variables获得的值相同,究其原因还在进一步研究中
root@localhost[information_schema]> select * from session_variables where variable_name='tx_isolation';
+---------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+---------------+----------------+
| TX_ISOLATION  | SERIALIZABLE   |
+---------------+----------------+

5、总结

b、检索设置

c、其他注意事项