HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Check for table corruption

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tablecheckforcorruption

Problem

I monitor MySQL databases by querying various things remotely. I recently came across an issue where by a table had become corrupted but I did not know about it until the daily mysqldump failed. Is there a way I can check for corruption (without running a CHECK TABLE on every table)? I thought I had it figured when I noticed information_schema.tables has a table_comment column which says this when it's corrupt:

TABLE_COMMENT: Table './demo/test' is marked as crashed and should be repaired


Turns out, when I try to search on that column, i.e. WHERE TABLE_COMMENT LIKE '%marked as crashed%', nothing is returned!

I need to be able to query this from a stored procedure, any suggestions?

Solution

When you issue

SHOW TABLE STATUS;


On the database in question, corrupted tables will be shown. They will have no row count or size, most of the properties will be null, and in Comment column you will see your text:


Table './demo/test' is marked as crashed and should be repaired

Code Snippets

SHOW TABLE STATUS;

Context

StackExchange Database Administrators Q#63322, answer score: 2

Revisions (0)

No revisions yet.