CHECK TABLE
Updated at:
Copy as MD
CHECK TABLE checks a table for errors — particularly tables that failed to be created by a DDL statement.
How it works
The behavior of CHECK TABLE depends on whether the target table is sharded.
| Table type | Check performed |
|---|---|
| Sharded table | Whether all underlying physical table shards exist, and whether the columns and indexes of each shard are consistent |
| Single-database non-sharded table | Whether the table exists |
Syntax
CHECK TABLE tbl_nameOutput columns
CHECK TABLE returns a result set with the following columns.
| Column | Description |
|---|---|
TABLE | The fully qualified table name, in the format schema.table_name |
OP | The operation type. Always check |
MSG_TYPE | The message type: status indicates the final result; Error indicates the check failed |
MSG_TEXT | The result message. OK indicates the check passed |
Examples
Successful check — the table exists and all shards are consistent:
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)Failed check — the table does not exist:
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)Is this page helpful?