use test;
create table test1 as select * from information_schema.tables;
alter table test1 engine = myisam; -- not even necessary
select * from information_schema.tables where table_name = 'test1'\G
delete from test1 limit 10;
select * from information_schema.tables where table_name = 'test1'\G
analyze table test1;
select * from information_schema.tables where table_name = 'test1'\G
optimize table test1;
select * from information_schema.tables where table_name = 'test1'\G
information_schema.tables 始终显示正确的数据长度,因此您可以将 data_length 字段与所需数据长度的粗略估计(avg_row_length * table_rows)进行比较,但前提是您已使用分析表更新了统计信息:
我对那个答案有一些第二个想法:-) 实际上它就像查找值一样简单——它都在 information_schema.tables 中!查找名为 data_free 的字段,它具有正确的值,并且在我所做的示例中也表现正确: