查看MySQL库、表所占磁盘空间大小

查询库:

SELECT 
TABLE_SCHEMA, 
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='notification'
GROUP BY TABLE_SCHEMA
ORDER BY data_size DESC;

查询表:

SELECT CONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),'MB') AS data_size,
CONCAT(TRUNCATE(SUM(max_data_length)/1024/1024,2),'MB') AS max_data_size,
CONCAT(TRUNCATE(SUM(data_free)/1024/1024,2),'MB') AS data_free,
CONCAT(TRUNCATE(SUM(index_length)/1024/1024,2),'MB') AS index_size
FROM information_schema.tables WHERE TABLE_NAME = 'alert_sub_info_esid';
原文地址:https://www.cnblogs.com/chong-zuo3322/p/14066959.html