This table exposes user-defined variables set within active threads, allowing inspection of custom variables across all sessions.
The user_variables_by_thread table contains information about user-defined variables and the threads that defined them.
TRUNCATE TABLE cannot be performed on the table.
The table contains the following columns:
This page is licensed: CC BY-SA / Gnu FDL
THREAD_ID
The thread identifier of the session in which the variable is defined.
VARIABLE_NAME
The variable name, without the leading @ character.
VARIABLE_VALUE
The variable value
SET @var = 0;
SELECT * FROM user_variables_by_thread;
+-----------+---------------+----------------+
| THREAD_ID | VARIABLE_NAME | VARIABLE_VALUE |
+-----------+---------------+----------------+
| 11 | var | 0 |
+-----------+---------------+----------------+