SET statement for setting variables

You can execute the SET statement to set various types of variables, such as 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 you execute the SET GLOBAL statement to set a global variable, the PolarDB-X instance persists the global variable. The configuration of the global variable takes effect after the instance is restarted. After the global variable is set by executing the SET GLOBAL statement, the configuration of the global variable takes effect for all existing connections.

Examples

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)

SELECT @@time_zone;
+-------------+
| @@time_zone |
+-------------+
| +09:00      |
+-------------+
1 row in set (0.00 sec)

SET GLOBAL time_zone='+09:00';
Query OK, 0 rows affected (0.04 sec)

SELECT @@GLOBAL.time_zone;
+--------------------+
| @@global.time_zone |
+--------------------+
| +09:00             |
+--------------------+
1 row in set (0.02 sec)

results matching ""

    No results matching ""