3 回答
TA贡献1795条经验 获得超7个赞
您可以使用此查询来显示表的大小(尽管您需要先替换变量):
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;
TA贡献1789条经验 获得超10个赞
SELECT TABLE_NAME AS "Table Name",
table_rows AS "Quant of Rows", ROUND( (
data_length + index_length
) /1024, 2 ) AS "Total Size Kb"
FROM information_schema.TABLES
WHERE information_schema.TABLES.table_schema = 'YOUR SCHEMA NAME/DATABASE NAME HERE'
LIMIT 0 , 30
您可以从“ information_schema ” - > SCHEMATA表 - >“ SCHEMA_NAME ”列中获取模式名称
附加 您可以获得如下的mysql数据库大小。
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
结果
DB Name | DB Size in MB
mydatabase_wrdp 39.1
information_schema 0.0
TA贡献1982条经验 获得超2个赞
SELECT
table_name AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) as size
FROM information_schema.TABLES
WHERE table_schema = "YOUR_DATABASE_NAME"
ORDER BY size DESC;
这会对大小进行排序(DB大小,以MB为单位)。
添加回答
举报