Comments - User-Defined Variables

1 week ago Jindrich Pachta

Use following queries to list User-Defined variables in active session

Create User-Defined variable @year:

SET @year=YEAR(NOW());

Brief list of User-Defined variables:

SHOW USER_VARIABLES;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| year          | 2025  |
+---------------+-------+

Detailed list of User-Defined variables:

SELECT * FROM information_schema.USER_VARIABLES;
+---------------+----------------+---------------+--------------------+
| VARIABLE_NAME | VARIABLE_VALUE | VARIABLE_TYPE | CHARACTER_SET_NAME |
+---------------+----------------+---------------+--------------------+
| year          | 2025           | INT           | latin1             |
+---------------+----------------+---------------+--------------------+

Both queries supports LIKE 'pattern' | WHERE expr clause.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.