MySQL 查询数据容量

SELECT
    table_schema AS '数据库',
    table_name AS '表名',
    table_rows AS '记录数',
    TRUNCATE ( data_length / 1024 / 1024, 2 ) AS '数据容量(MB)',
    TRUNCATE ( index_length / 1024 / 1024, 2 ) AS '索引容量(MB)' 
FROM
    information_schema.tables 
WHERE
    table_schema = '数据库名称' 
ORDER BY
    table_rows DESC,
    index_length DESC;

 

posted @ 2023-02-10 08:57  Mr_Xul  阅读(29)  评论(0编辑  收藏  举报