MySQL server SQL Mode bitsCN.com
SQL _mode system variables can regulate MySQL SQL Mode
Any client can change the MySQL server's response to itself without affecting other clients.
If you want to set the SQL Mode when MySQL starts, you can add the SQL _mode option to the mysql configuration file.
SQL-mode = "TRADITIONAL"
If you modify the SQL mode during running, you can use the following command:
Setsql_mode = "TRADITIONAL ";
Client1
Mysql> show variables like "SQL _mode ";
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| SQL _mode |
+ --------------- + ------- +
1 row in set (0.00 sec)
Mysql> set SQL _mode = "TRADITIONAL ";
Query OK, 0 rows affected (0.23 sec)
Mysql> show variables like "SQL _mode ";
+ --------------- + Response ---------------------------------------------------------------------------------------------------------
| Variable_name | Value |
+ --------------- + Response -----------------------------------------------------------------------------------------------------------
| SQL _mode | STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO
_ DATE, ERROR_FOR_pISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO _
ENGINE_SUBSTITUTION |
+ --------------- + Response ------------------------------------------------------------------------------------------------------------
1 rowin set (0.00 sec)
Mysql>
Client2
Client1 has modified the SQL mode, but the SQL Mode of Client2 has not changed. This indicates that the mode between clients is modified.
They do not affect each other.
Mysql> show variables like "SQL _mode ";
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| SQL _mode |
+ --------------- + ------- +
1 row in set (0.00 sec)
Mysql>
Set GLOBAL variables (to set GLOBAL variables, add the GLOBAL keyword and require the SUPER permission)
Mysql> set globalsql_mode = "traditional ";
Query OK, 0 rows affected (0.02 sec)
Select @ session. SQL _mode -- view the SQL mode of the current session
Select @ GLOBAL. SQL _mode -- View system session SQL Mode
After global variables are set, the new client is connected to the global SQL mode by default.
BitsCN.com