当遇到数据库占用空间很大的情况下,可以用以下语句查找大数据量的表
SELECT TABLE_NAME ,round((DATA_LENGTH/1024/1024),2) 'DATA_SIZE(M)' ,round((INDEX_LENGTH/1024/1024),2) 'INDEX_SIZE(M)' ,AVG_ROW_LENGTH ,MAX_DATA_LENGTH ,CREATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA ='库名' ORDER BY 2 desc;
运行结果