mySql 查询数据库大小
查看某个数据库大小
USE information_schema;
SELECT CONCAT(ROUND(SUM(data_length/1024/1024),2),'MB') AS DATA FROM TABLES WHERE table_schema='数据库名称';
查看数据库某个表大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='数据库名' and table_name='表名';
查看指定数据库各表大小
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 data_length DESC, index_length DESC;