利用sql來查看資料庫所占空間

選擇你的資料庫
use database;

SHOW TABLE STATUS;

Data_length + Index_length 就是大小,單位是bytes.

在[1]下方有kevingo網友提供一個複雜的語法來查看

SELECT concat(table_schema,'.',table_name),
concat(round(table_rows/1000000,2),'M') rows,
concat(round(data_length/(1024*1024*1024),2),'G') DATA,
concat(round(index_length/(1024*1024*1024),2),'G') idx,
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(index_length/data_length,2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length+index_length DESC LIMIT 20;

此文章來源為 http://note.tc.edu.tw/860.html

arrow
arrow
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()