Safe method to rename a crashed myisam table I have a large MyISAM table which has crashed. Repairing the table will take some time. The table only INSERTed to and SELECTed from, never updated. To allow the application to continue working, albeit with reduced capability, I thought of


renaming the crashed table
creating a new table with the original name
switching processing back on
repairing the backup table
switching off processing
merging the repaired and new data
switching on processing


The other steps in this process do not pose any risk due to the nature of the application.
Is it safe to rename a crashed MyISAM table? How?

I believe that I can't simply do ALTER TABLE...RENAME.... as this always does a row-by-row copy into a new table.

Apparently Peter Zaitsev uses a "tiny script which moves out all MyISAM tables out of MySQL database directory" but doesn't seem to give details of what this script does (presumably stops database first?).
This might work; do it with caution:

CREATE TABLE new LIKE real;   -- copy schema
RENAME TABLE real TO bad, new TO real;  -- replace broken table with empty
REPAIR TABLE bad;     -- slowly repair
RENAME TABLE real TO old, bad TO real;  -- replace empty table with fixed table
DROP TABLE old;   -- clean up


I don't know if the CREATE will work with a broken real.

The RENAMEs are 'instantaneous'.

Then schedule moving to InnoDB.