mysql命令-查詢資料庫佔用磁碟
阿新 • • 發佈:2018-11-10
查詢所有的資料庫
USE information_schema;
SELECT TABLE_SCHEMA,
CONCAT(TRUNCATE(SUM(`data_length` + `index_length`)/1024/1024/1024,4),' GB') AS data,
CONCAT(TRUNCATE(SUM(`data_length`)/1024/1024,2),' MB') AS data_size,
CONCAT(TRUNCATE(SUM(`index_length`)/1024/1024,2),'MB') AS index_size
FROM information_schema.tables
GROUP BY TABLE_SCHEMA
ORDER BY SUM(`data_length` + `index_length`) DESC;
查詢單個數據庫
USE information_schema;
SELECT TABLE_SCHEMA,
CONCAT(TRUNCATE(SUM(`data_length` + `index_length`)/1024/1024/1024,4),' GB') AS data,
CONCAT(TRUNCATE(SUM(`data_length`)/1024/1024,2),' MB') AS data_size,
CONCAT(TRUNCATE(SUM(`index_length` )/1024/1024,2),'MB') AS index_size
FROM information_schema.tables
WHERE TABLE_SCHEMA = '資料庫名稱'
GROUP BY TABLE_SCHEMA
ORDER BY SUM(`data_length` + `index_length`) DESC;