是否有可能只显示MySQL“show variables”中的值?

时间:2011-11-08 05:30:49

标签: mysql variables

查找MySQL变量值是一项简单的任务:

mysql> show variables where Variable_name = 'version';
+---------------+--------------------+
| Variable_name | Value              |
+---------------+--------------------+
| version       | 5.0.19-Max         |
+---------------+--------------------+
1 row in set (0.00 sec)

但是有没有任何语法允许只选择具有变量值的列,如下所示:

mysql> command_i_want_to_know
+--------------------+
| Value              |
+--------------------+
| 5.0.19-Max         |
+--------------------+
1 row in set (0.00 sec)

2 个答案:

答案 0 :(得分:29)

另一个变种 -

SELECT @@version;

答案 1 :(得分:8)

select variable_value 
from information_schema.global_variables
where variable_name = 'version';