本文介绍了CHECK TABLE语句的用法。
CHECK TABLE用于对数据表进行检查,主要用于DDL建表失败的情形。
- 对于拆分表,检查底层物理分表是否有缺失的情况,底层的物理分表的列和索引是否一致;
- 对于单库单表,检查表是否存在。
语法
CHECK TABLE tbl_name
示例
mysql> check table tddl_mgr_log;
+------------------------+-------+----------+----------+
| TABLE | OP | MSG_TYPE | MSG_TEXT |
+------------------------+-------+----------+----------+
| TDDL5_APP.tddl_mgr_log | check | status | OK |
+------------------------+-------+----------+----------+
1 row in set (0.56 sec)
mysql> check table tddl_mg;
+-------------------+-------+----------+----------------------------------------+
| TABLE | OP | MSG_TYPE | MSG_TEXT |
+-------------------+-------+----------+----------------------------------------+
| TDDL5_APP.tddl_mg | check | Error | Table 'tddl5_00.tddl_mg' doesn't exist |
+-------------------+-------+----------+----------------------------------------+
1 row in set (0.02 sec)