ADMIN CHECKSUM TABLE

The ADMIN CHECKSUM TABLE statement calculates a CRC64 checksum for the data and indexes of a table. This statement is used by programs such as TiDB Lightning to ensure that import operations have completed successfully.

Synopsis

AdminStmt

ADMIN CHECKSUM TABLE - 图1

TableNameList

ADMIN CHECKSUM TABLE - 图2

  1. AdminStmt ::=
  2. 'ADMIN' ( 'SHOW' ( 'DDL' ( 'JOBS' Int64Num? WhereClauseOptional | 'JOB' 'QUERIES' NumList )? | TableName 'NEXT_ROW_ID' | 'SLOW' AdminShowSlow ) | 'CHECK' ( 'TABLE' TableNameList | 'INDEX' TableName Identifier ( HandleRange ( ',' HandleRange )* )? ) | 'RECOVER' 'INDEX' TableName Identifier | 'CLEANUP' ( 'INDEX' TableName Identifier | 'TABLE' 'LOCK' TableNameList ) | 'CHECKSUM' 'TABLE' TableNameList | 'CANCEL' 'DDL' 'JOBS' NumList | 'RELOAD' ( 'EXPR_PUSHDOWN_BLACKLIST' | 'OPT_RULE_BLACKLIST' | 'BINDINGS' ) | 'PLUGINS' ( 'ENABLE' | 'DISABLE' ) PluginNameList | 'REPAIR' 'TABLE' TableName CreateTableStmt | ( 'FLUSH' | 'CAPTURE' | 'EVOLVE' ) 'BINDINGS' )
  3. TableNameList ::=
  4. TableName ( ',' TableName )*

Examples

Create table t1:

  1. CREATE TABLE t1(id INT PRIMARY KEY);

Insert some data into t1:

  1. INSERT INTO t1 VALUES (1),(2),(3);

Calculate the checksum for t1:

  1. ADMIN CHECKSUM TABLE t1;

The output is as follows:

  1. +---------+------------+----------------------+-----------+-------------+
  2. | Db_name | Table_name | Checksum_crc64_xor | Total_kvs | Total_bytes |
  3. +---------+------------+----------------------+-----------+-------------+
  4. | test | t1 | 10909174369497628533 | 3 | 75 |
  5. +---------+------------+----------------------+-----------+-------------+
  6. 1 row in set (0.00 sec)

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.