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 PRIMARY KEY);

插入一些数据:

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

计算表 t1 的校验和:

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 语法的扩展。

文档内容是否有帮助?