-- 统计MySQL数据表大小
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_schema = 'db_name';
-- 统计数据库表数量
SELECT COUNT(*) FROM information_schema.TABLES where TABLE_SCHEMA = 'db_name';
-- 统计数据库各表行数
select table_name,table_rows from information_schema.tables
where table_schema = 'db_name' order by table_rows desc