Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to show only value in MySQL "show variables"?

It is an easy task to find MySQL variable values:

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

But is there any syntax that allows to select only column with variable value, like so:

mysql> command_i_want_to_know
+--------------------+
| Value              |
+--------------------+
| 5.0.19-Max         |
+--------------------+
1 row in set (0.00 sec)
like image 885
bessarabov Avatar asked Nov 08 '11 05:11

bessarabov


People also ask

How do you display the value of a variable in MySQL?

SET @yourVariableName = yourValue; Let us check the above syntax to create a variable and display the value of created variable.

Can we store value in variable in MySQL?

The user-defined variable enables us to store a value in one statement and later can refer it to another statement. MySQL provides a SET and SELECT statement to declare and initialize a variable.

How do you assign a value to a variable in MySQL?

There are two ways to assign a value to a user-defined variable. You can use either := or = as the assignment operator in the SET statement. For example, the statement assigns number 100 to the variable @counter. The second way to assign a value to a variable is to use the SELECT statement.

How do I view variables in MySQL workbench?

-- Syntax to Declare/Set a Global variable SET GLOBAL sort_buffer_size = 500000; SET @@global. sort_buffer_size = 500000; -- Syntax to Declare/Set a Session variable SET sort_buffer_size = 500000; SET SESSION sort_buffer_size = 500000; SET @@sort_buffer_size = 500000; SET @@local.


2 Answers

One more variant -

SELECT @@version;
like image 62
Devart Avatar answered Sep 30 '22 19:09

Devart


select variable_value 
from information_schema.global_variables
where variable_name = 'version';
like image 38
Jim H. Avatar answered Sep 30 '22 17:09

Jim H.