mysql資料庫容量查詢

木子小僧發表於2016-08-09

1、統計每張表的資料量
SELECT
*
FROM
(
select
TABLE_NAME,
concat(
round(
sum(DATA_LENGTH / 1024 / 1024 ),
7
)

) as size
from
information_schema. tables
where
table_schema = 'platform_all_edu'
GROUP BY
table_name
) t;

2、統計每張表的資料容量(資料量+索引)
select
table_name,
(
sum(DATA_LENGTH) + sum(INDEX_LENGTH)
) / 1024 / 1024 as size
from
information_schema. tables
where
table_schema = 'platform_all_edu'
GROUP BY
table_name;

3、檢視資料庫資料量

SELECT concat(round(sum(DATA_LENGTH / 1024 / 1024 / 1024), 2), 'G')
FROM information_schema. tables
WHERE table_schema= 'platform_all_edu' ;

相關文章