MariaDB [(none)]> SET @good = 10;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW VARIABLES LIKE 'good';
Empty set (0.07 sec)
如何显示由SET运算符初始化的所有变量?
答案 0 :(得分:2)
对于MySQL,请使用:
select * from performance_schema.user_variables_by_thread;
mysql> SET @good = 10;
Query OK, 0 rows affected (0.00 sec)
mysql> SET @bad = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from performance_schema.user_variables_by_thread;
+-----------+---------------+----------------+
| THREAD_ID | VARIABLE_NAME | VARIABLE_VALUE |
+-----------+---------------+----------------+
| 36922 | bad | 0 |
| 36922 | good | 10 |
+-----------+---------------+----------------+
2 rows in set (0.00 sec)
对于MariaDB,目前尚不支持:
https://mariadb.com/kb/en/mariadb/information-schema-user_variables-table/
<强> The USER_VARIABLES table will be introduced in MariaDB 10.2.0 as part of the user_variables plugin.
强>