Purpose
You can use this statement to set a user-defined variable (@) or system session variable (@@).
Syntax
SET variable_name = variable_value[,variable_name = variable_value...];
Parameters
| Parameter | Description |
|---|---|
| variable_name | The name of the variable to be set, which can be a user-defined variable or a system variable. To set multiple variables, separate them with commas (,). |
| variable_value | The value of the variable. |
Examples
obclient> SET @a = 1, @b = 2, @c = 3;
Query OK, 0 rows affected
obclient> SET @@tx_isolation = 'read-committed';
Query OK, 0 rows affected
obclient> SELECT @a,@b,@c,@@tx_isolation FROM DUAL;
+------+------+------+----------------+
| @A | @B | @C | @@TX_ISOLATION |
+------+------+------+----------------+
| 1 | 2 | 3 | READ-COMMITTED |
+------+------+------+----------------+
1 row in set