mysql系列-常用語句

一 查看空間碎片-庫維度

    

select

table_schema as '數據庫',

sum(table_rows) as '記錄數',

sum(truncate(data_length/1024/1024/1024, 2)) as '數據容量(GB)',

sum(truncate(index_length/1024/1024/1024, 2)) as '索引容量(GB)',

sum(truncate(data_free/1024/1024/1024, 2)) as '空間碎片(GB)'

from information_schema.tables

group by table_schema

 二 查看空間碎片-表維度 

select

table_name as '數據庫',

table_rows as '記錄數',

truncate(data_length/1024/1024/1024, 2) as '數據容量(GB)',

truncate(index_length/1024/1024/1024, 2) as '索引容量(GB)',

truncate(data_free/1024/1024/1024, 2) as '空間碎片(GB)'

from information_schema.tables WHERE TABLE_SCHEMA='xxx' order by 

data_free desc limit 10

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章