MySql 查询来获取数据库的数据大小
这个查询会返回每个数据库的名称和它们占用的总大小(以MB为单位)。data_length
是表数据占用的大小,index_length
是表索引占用的大小。
SELECT
table_schema AS "数据库",
SUM(data_length + index_length) / 1024 / 1024 AS "sizeMB"
FROM
information_schema. TABLES
GROUP BY
table_schema
ORDER BY
sizeMB DESC
Mysql查询数据表中的数据量以及数据大小
SELECT
table_schema AS '数据库',
table_name AS '表名',
table_rows AS '记录数',
TRUNCATE (data_length / 1024 / 1024, 2) AS '数据容量(MB)',
TRUNCATE (index_length / 1024 / 1024, 2) AS '索引容量(MB)'
FROM
information_schema. TABLES
ORDER BY
data_length DESC,
index_length DESC