#数据库中统计表大小
SELECT
table_name AS '表名',
ROUND(data_length / 1024 / 1024, 2) AS '数据大小(MB)',
ROUND(index_length / 1024 / 1024, 2) AS '索引大小 (MB)',
round((data_length+index_length)/1024/1024,2) as '总大小(MB)',
table_rows as '行数'
FROM
information_schema.tables
WHERE
table_schema = 'your_database'
order by (data_length+index_length) desc;
select sum(total) as '总大小(MB)' from (SELECT
table_name AS '表名',
ROUND(data_length / 1024 / 1024, 2) AS '数据大小(MB)',
ROUND(index_length / 1024 / 1024, 2) AS '索引大小(MB)',
round((data_length+index_length)/1024/1024,2) as total,
table_rows as '行数'
FROM
information_schema.tables
WHERE
table_schema = 'your_database'
order by (data_length+index_length) desc) as t;

07-02
475
475
08-27
2698
2698

被折叠的 条评论
为什么被折叠?



