Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.96 KB

variable.md

File metadata and controls

50 lines (34 loc) · 1.96 KB
title summary category
The System Variables
Learn how to use the system variables in TiDB.
user guide

The System Variables

The system variables in MySQL are the system parameters that modify the operation of the database runtime. These variables have two types of scope, Global Scope and Session Scope. TiDB supports all the system variables in MySQL 5.7. Most of the variables are only supported for compatibility and do not affect the runtime behaviors.

Set the system variables

You can use the SET statement to change the value of the system variables. Before you change, consider the scope of the variable. For more information, see MySQL Dynamic System Variables.

Set Global variables

Add the GLOBAL keyword before the variable or use @@global. as the modifier:

SET GLOBAL autocommit = 1;
SET @@global.autocommit = 1;

Set Session Variables

Add the SESSION keyword before the variable, use @@session. as the modifier, or use no modifier:

SET SESSION autocommit = 1;
SET @@session.autocommit = 1;
SET @@autocommit = 1;

Note: LOCAL and @@local. are the synonyms for SESSION and @@session.

The fully supported MySQL system variables in TiDB

The following MySQL system variables are fully supported in TiDB and have the same behaviors as in MySQL.

Name Scope Description
autocommit GLOBAL | SESSION whether automatically commit a transaction
sql_mode GLOBAL | SESSION support some of the MySQL SQL modes
time_zone GLOBAL | SESSION the time zone of the database
tx_isolation GLOBAL | SESSION the isolation level of a transaction
hostname NONE the hostname of the TiDB server

TiDB Specific System Variables

See TiDB Specific System Variables.