我可以运行这个查询来获取 MySQL 数据库中所有表的大小:
show table status from myDatabaseName;
我需要一些帮助来理解结果。我正在寻找尺寸最大的 table 。
我应该看哪一栏?
最佳答案
您可以使用此查询来显示表的大小(尽管您需要先替换变量):
SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "$DB_NAME"
AND table_name = "$TABLE_NAME";
或者这个查询列出每个数据库中每个表的大小,最大的在前:
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
https://stackoverflow.com/questions/9620198/