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

  

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