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

TA貢獻1795條經(jīng)驗 獲得超7個贊
您可以使用此查詢來顯示表的大?。ūM管您需要先替換變量):
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";
或者此查詢列出每個數(shù)據(jù)庫中每個表的大小,最大的第一個:
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條經(jīng)驗 獲得超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數(shù)據(jù)庫大小。
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條經(jīng)驗 獲得超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為單位)。
添加回答
舉報