SET Statement Variable Configuration
You can set various types of variables using the SET statement, including user-defined variables, session variables, and global variables.
Syntax
SET variable = expr [, variable = expr] ...
variable: {
user_var_name
| {GLOBAL | @@GLOBAL.} system_var_name
| [SESSION | @@SESSION. | @@] system_var_name
}
Note
When setting global variables with SET GLOBAL, PolarDB-X will persist them, so they remain effective even after an instance restart. Furthermore, once the SET GLOBAL configuration is successful, it will take effect for all existing connections.
Example
mysql> SET @foo='bar';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @foo;
+------+
| @foo |
+------+
| bar |
+------+
1 row in set (0.01 sec)
mysql> SET @@time_zone='+09:00';
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT @@time_zone;
+-------------+
| @@time_zone |
+-------------+
| +09:00 |
+-------------+
1 row in set (0.00 sec)
mysql> SET GLOBAL time_zone='+09:00';
Query OK, 0 rows affected (0.04 sec)
mysql> SELECT @@GLOBAL.time_zone;
+--------------------+
| @@global.time_zone |
+--------------------+
| +09:00 |
+--------------------+
1 row in set (0.02 sec)