Errors like this can occur when the MyISAM table becomes corrupted. The recovery command in the table in question is usually required to correct it:
> repair table mytablename;
The best solution is not to use MyISAM for tables where data is constantly changing - InnoDB is much more bulletproof, and, as Paul correctly points out, you can use transactions on InnoDB tables, but not in MyISAM.
By the way, I would not rename the tables on the fly - this is a rather clumsy thing that needs to be done on a regular basis, and can lead to very unexpected results if you ever have other users on the system while renaming to. Why not just do something like this:
> truncate table temptable; > truncate table importtable; >
Of course, if you insert a very large number of rows, then the risk will be that all your data in real time is not available until the insert is completed, but in general this approach is much less damaging to indexes, triggers, or anything else , which may be related to the tables under consideration.
Simon woolf
source share