gpt4 book ai didi

mysql - 如何获取 MySQL 数据库表的大小?

转载 作者:IT老高 更新时间:2023-10-28 12:47:22 24 4
gpt4 key购买 nike

我可以运行这个查询来获取 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;

关于mysql - 如何获取 MySQL 数据库表的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9620198/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com