如何獲取MySQL數(shù)據(jù)庫(kù)表的大?。?/h1>
3 回答

TA貢獻(xiàn)1795條經(jīng)驗(yàn) 獲得超7個(gè)贊
您可以使用此查詢來(lái)顯示表的大小(盡管您需要先替換變量):
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";
或者此查詢列出每個(gè)數(shù)據(jù)庫(kù)中每個(gè)表的大小,最大的第一個(gè):
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貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊
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數(shù)據(jù)庫(kù)大小。
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;
結(jié)果
DB Name | DB Size in MB
mydatabase_wrdp 39.1
information_schema 0.0

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊
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;
這會(huì)對(duì)大小進(jìn)行排序(DB大小,以MB為單位)。
添加回答
舉報(bào)