eskysky
Published on 2025-11-06 / 8 Visits
0

MySQL查询指定数据库占用空间大小

执行以下SQL

SELECT table_schema AS 'Database',
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size (MB)'
FROM information_schema.TABLES
WHERE table_schema = '数据库名'
GROUP BY table_schema;

功能:用于查询 MySQL 数据库中指定数据库所占用的总磁盘空间大小(包括数据和索引),并以 MB 为单位展示。