背景:如今大量的MySQL服務遷移到雲上了,因此當發生空間佔用的時候,分析哪一個表佔用較多就很麻煩,若是快速鎖定元兇呢?數據庫
一句話鎖定元兇ide
select table_schema as '數據庫名稱', sum(table_rows) as '記錄總數', sum(truncate(data_length/1024/1024, 2)) as '數據容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc;
提取出來的數據一目瞭然,好好看看如何修理大表吧!code