Mysql查看库表数据容量和记录行

一、库大小

SELECT 
table_schema AS '数据库',
SUM(table_rows) AS '记录数',
SUM(TRUNCATE(data_length/1024/1024, 2)) AS '数据容量(MB)',
SUM(TRUNCATE(index_length/1024/1024, 2)) AS '索引容量(MB)'
FROM information_schema.tables
WHERE table_schema='table';

二、表大小

    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='table' ;

你可能感兴趣的:(mysql,数据库)