With the long-term use of mysql, some problems may occur. In general, mysql tables cannot be accessed, and the tables can be repaired. During optimization, the disk space is reduced. Convenient backup.
With the long-term use of mysql, some problems may occur. In general, mysql tables cannot be accessed, and the tables can be repaired. During optimization, the disk space is reduced. Convenient backup.
The Code is as follows:
Repair table 'table _ name' REPAIR table
Optimize table 'table _ name' OPTIMIZE table
Repair table is used to REPAIR damaged tables.
Optimize table is used to recycle idle database space. When the data rows in the TABLE are deleted, the occupied disk space is not immediately recycled, after the optimize table command is used, the space will be recycled and the data rows on the disk will be rearranged (Note: it is on the disk rather than the database ).
Optimize table does not need to be run most of the time. You only need to perform a data TABLE optimization operation after batch deletion of data rows, or regularly (once a week or once a month), only for those specific tables.