查询mysql数据量,表数量脚本

发布时间 2023-11-14 11:32:06作者: 东峰叵,com
#  查询数据库中每个库的数据量
SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
#  查询数据库中每个库的表数据量
SELECT TABLE_SCHEMA, COUNT(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;