2020/09/03
mysql查看當(dāng)前所有的數(shù)據(jù)庫(kù)和索引大小
select table_schema, concat(truncate(sum(data_length)/1024/1024,2),' mb') as data_size,
concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size
from information_schema.tables
group by table_schema
order by data_length desc;
查詢單獨(dú)數(shù)據(jù)庫(kù)大小
SELECT
table_schema AS 'DB Name',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS 'DB Size in MB'
FROM
information_schema.tables
WHERE
table_schema = '數(shù)據(jù)庫(kù)名稱'
GROUP BY
table_schema;
mysql查看當(dāng)前某個(gè)數(shù)據(jù)庫(kù)和數(shù)據(jù)庫(kù)下所有的表的大小
select table_name, concat(truncate(data_length/1024/1024,2),' mb') as data_size,
concat(truncate(index_length/1024/1024,2),' mb') as index_size
from information_schema.tables where table_schema = 'ops_monitor'? ? ?#這個(gè)修改為數(shù)據(jù)庫(kù)名稱
group by table_name
order by data_length desc;