Checking, Repairing, and Optimizing Using SQL Commands

So far you've looked at how to use myisamchk as a convenient command-line utility. However, its commands have SQL equivalents as you will now see, in the form of CHECK TABLE, REPAIR TABLE, and OPTIMIZE TABLE.

Although some of the utilities you've seen earlier today work best with mysqld stopped, these commands are SQL queries and therefore need the MySQL server to be running to execute them!

Using CHECK TABLE

The syntax for CHECK TABLE is

CHECK TABLE table_name[,table_name,...] [options]

You can use it to check a single table or a list of tables separated by commas.

CHECK TABLE checks a table for errors and updates the table's key statistics. Running it returns a resultset showing the status ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition 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.