Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 2.2 KB

sql-statement-admin-checksum-table.md

File metadata and controls

70 lines (46 loc) · 2.2 KB
title summary category
ADMIN CHECKSUM TABLE | TiDB SQL Statement Reference
An overview of the usage of ADMIN for the TiDB database.
reference

ADMIN CHECKSUM TABLE

The ADMIN CHECKSUM TABLE statement calculates a CRC64 checksum for the data and indexes of a table.

The checksum is calculated based on table data and properties such as table_id. This means that two tables with the same data but different table_id values will get different checksums.

After importing a table using TiDB Lightning, TiDB Data Migration, or IMPORT INTO, ADMIN CHECKSUM TABLE <table> is executed by default to validate data integrity.

The checksum is calculated over the table data and properties like the table_id. This means that two tables with the same data but different table_id values will get different checksums.

After importing a table using IMPORT INTO, ADMIN CHECKSUM TABLE <table> is executed by default to validate data integrity.

Synopsis

AdminChecksumTableStmt ::=
    'ADMIN' 'CHECKSUM' 'TABLE' TableNameList

TableNameList ::=
    TableName ( ',' TableName )*

Examples

Create table t1:

CREATE TABLE t1(id INT PRIMARY KEY);

Insert some data into t1:

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

Calculate the checksum for t1:

ADMIN CHECKSUM TABLE t1;

The output is as follows:

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

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.