- 将 your_database_name 替换为你要查询的数据库名称。这个查询将显示指定数据库中每个表的大小,按总大小(数据长度和索引长度之和)从大到小排序,并以 MB 为单位显示。
SELECT
table_schema AS `Database`,
table_name AS `Table`,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS `Size (MB)`
FROM
information_schema.tables
WHERE
table_schema = 'your_database_name'
ORDER BY
(data_length + index_length) DESC;