title | category |
---|---|
Database Administration Statements |
user guide |
TiDB manages the database using a number of statements, including granting privileges, modifying system variables, and querying database status.
See Privilege Management.
The SET
statement has multiple functions and forms.
SET variable_assignment [, variable_assignment] ...
variable_assignment:
user_var_name = expr
| param_name = expr
| local_var_name = expr
| [GLOBAL | SESSION]
system_var_name = expr
| [@@global. | @@session. | @@]
system_var_name = expr
You can use the above syntax to assign values to variables in TiDB, which include system variables and user-defined variables. All user-defined variables are session variables. The system variables set using @@global.
or GLOBAL
are global variables, otherwise session variables. For more information, see The System Variables.
SET {CHARACTER SET | CHARSET}
{'charset_name' | DEFAULT}
SET NAMES {'charset_name'
[COLLATE 'collation_name'] | DEFAULT}
This statement sets three session system variables (character_set_client
, character_set_results
and character_set_connection
) as given character set. Currently, the value of character_set_connection
differs from MySQL and is set as the value of character_set_database
in MySQL.
SET PASSWORD [FOR user] = password_option
password_option: {
'auth_string'
| PASSWORD('auth_string')
}
This statement is used to set user passwords. For more information, see Privilege Management.
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
This statement is used to set the transaction isolation level. For more information, see Transaction Isolation Level.
TiDB supports part of SHOW
statements, used to view the Database/Table/Column information and the internal status of the database. Currently supported statements:
# Supported and similar to MySQL
SHOW CHARACTER SET [like_or_where]
SHOW COLLATION [like_or_where]
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
SHOW CREATE {DATABASE|SCHEMA} db_name
SHOW CREATE TABLE tbl_name
SHOW DATABASES [like_or_where]
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW [GLOBAL | SESSION] STATUS [like_or_where]
SHOW TABLE STATUS [FROM db_name] [like_or_where]
SHOW [FULL] TABLES [FROM db_name] [like_or_where]
SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
SHOW WARNINGS
# Supported to improve compatibility but return null results
SHOW ENGINE engine_name {STATUS | MUTEX}
SHOW [STORAGE] ENGINES
SHOW PLUGINS
SHOW PROCEDURE STATUS [like_or_where]
SHOW TRIGGERS [FROM db_name] [like_or_where]
SHOW EVENTS
SHOW FUNCTION STATUS [like_or_where]
# TiDB-specific statements for viewing statistics
SHOW STATS_META [like_or_where]
SHOW STATS_HISTOGRAMS [like_or_where]
SHOW STATS_BUCKETS [like_or_where]
like_or_where:
LIKE 'pattern'
| WHERE expr
Note:
- To view statistics using the
SHOW
statement, see View Statistics.- For more information about the
SHOW
statement, see SHOW Syntax in MySQL.
This statement is a TiDB extension syntax, used to view the status of TiDB.
ADMIN SHOW DDL
ADMIN SHOW DDL JOBS
ADMIN CANCEL DDL JOBS 'job_id' [, 'job_id'] ...
-
ADMIN SHOW DDL
: To view the currently running DDL jobs. -
ADMIN SHOW DDL JOBS
: To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue. -
ADMIN CANCEL DDL JOBS 'job_id' [, 'job_id'] ...
: To cancel the currently running DDL jobs and return whether the corresponding jobs are successfully cancelled. If the operation fails to cancel the jobs, specific reasons are displayed.Note:
- This operation can cancel multiple DDL jobs at the same time. You can get the ID of DDL jobs using the
ADMIN SHOW DDL JOBS
statement. - If the jobs you want to cancel are finished, the cancellation operation fails.
- This operation can cancel multiple DDL jobs at the same time. You can get the ID of DDL jobs using the