Name

REPAIR TABLE

Synopsis

REPAIR [LOCAL|NO_WRITE_TO_BINLOG] TABLE
    table[, ...] [QUICK] [EXTENDED] [USE_FRM]

Use this statement to repair corrupted MyISAM tables. Multiple tables may be given in a comma-separated list. To prevent this statement from recording its activities in the binary log file, the NO_WRITE_TO_BINLOG flag or its LOCAL alias may be given. The QUICK flag instructs MySQL to repair the table indexes only. The EXTENDED flag is for rebuilding the indexes one row at a time. This option takes longer, but can be more effective, especially with rows containing duplicate keys. Before running this statement, make a backup of the table. If a table continues to have problems, there may be other problems (e.g., filesystem problems) that you should consider. Here is an example of this statement:

REPAIR TABLE systems QUICK EXTENDED;
+----------------------+--------+----------+----------+
| Table                | Op     | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| workrequests.systems | repair | status   | OK       |
+----------------------+--------+----------+----------+

In this example, the repair was successful. This is indicated by the OK in the Msg_text field. If it were unsuccessful, you could try the USE_FRM option with this statement. This option will create a new index file (.MYI) using the table schema file (.frm). It won’t be able to determine the current value for AUTO_INCREMENT columns or for DELETE LINK, so it shouldn’t be used unless the original .MYI file ...

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.