查看表碎片大小
一、查看某个表的碎片大小
mysql> SHOW TABLE STATUS LIKE table_name;
结果中’Data_free’列的值就是碎片大小
(2)列出所有已经产生碎片的表
mysql> select table_schema db, table_name, data_free, engine from information_schema.tables where table_schema not in ('information_schema', 'mysql') and data_free > 0;
清除表碎片
(1)MyISAM表
mysql> optimize table 表名
备注(个人实测):如果drop掉表的field(字段),表所使用的空间可能会增加,若需移除这部分空间。处理方案是修复表
REPAIR TABLE table_name;
修复表最好少用,且修复过程中不可中断,否者会发生未知的错误,谨慎使用
(2)InnoDB表
mysql> alter table 表名 engine=InnoDB