如何列出 MySQL 中由 SET 运算符初始化的所有变量?
mysqlmysqli database
要列出由 SET 运算符初始化的所有变量,语法如下 −
select * from performance_schema.user_variables_by_thread;
以下是设置变量的查询 −
mysql> set @FirstName='John'; Query OK, 0 rows impacted (0.00 sec) mysql> set @LastName='Doe'; Query OK, 0 rows impacted (0.00 sec)
以下是显示由 SET 运算符初始化的所有变量列表的查询。此列表包括上面设置的变量−
mysql> select * from performance_schema.user_variables_by_thread;
这将产生以下输出 −
+-----------+---------------+----------------+ | THREAD_ID | VARIABLE_NAME | VARIABLE_VALUE | +-----------+---------------+----------------+ | 120 | TotalAmount | 5000 | | 120 | FirstName | John | | 120 | lName | Smith | | 120 | fName | Adam | | 120 | LastName | Doe | +-----------+---------------+----------------+ 5 rows in set (0.00 sec)