ADMIN CHECKSUM TABLE

ADMIN CHECKSUM TABLE 语句用于计算表中所有行和索引的 CRC64 校验和。在 TiDB Lightning 等程序中,可通过此语句来确保导入操作成功。

语法图

AdminStmt
ADMINSHOWDDLJOBSInt64NumWhereClauseOptionalJOBQUERIESNumListTableNameNEXT_ROW_IDSLOWAdminShowSlowCHECKTABLETableNameListINDEXTableNameIdentifierHandleRange,RECOVERINDEXTableNameIdentifierCLEANUPINDEXTableNameIdentifierTABLELOCKTableNameListCHECKSUMTABLETableNameListCANCELDDLJOBSNumListRELOADEXPR_PUSHDOWN_BLACKLISTOPT_RULE_BLACKLISTBINDINGSPLUGINSENABLEDISABLEPluginNameListREPAIRTABLETableNameCreateTableStmtFLUSHCAPTUREEVOLVEBINDINGS
TableNameList
TableName,

示例

计算表 t1 的校验和:

CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY auto_increment); INSERT INTO t1 VALUES (1),(2),(3); ADMIN CHECKSUM TABLE t1;
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY auto_increment); Query OK, 0 rows affected (0.11 sec) INSERT INTO t1 VALUES (1),(2),(3); Query OK, 3 rows affected (0.02 sec) Records: 3 Duplicates: 0 Warnings: 0 ADMIN CHECKSUM TABLE t1; +---------+------------+----------------------+-----------+-------------+ | Db_name | Table_name | Checksum_crc64_xor | Total_kvs | Total_bytes | +---------+------------+----------------------+-----------+-------------+ | test | t1 | 10909174369497628533 | 3 | 75 | +---------+------------+----------------------+-----------+-------------+ 1 row in set (0.00 sec)

MySQL 兼容性

ADMIN CHECKSUM TABLE 语句是 TiDB 对 MySQL 语法的扩展。