#查看每个数据库占用的空间:
Select Table_schema "Database Name", sum (data_length + index_length)/1024/1024 "database Size in MB" from Informatio N_schema. TABLES GROUP by Table_schema;
#查看数据库下每个表和索引占用的空间:
Select table_name as "Tables", Round (((data_length + index_length)/1024/1024), 2) "Size in MB"
From INFORMATION_SCHEMA. TABLES
WHERE table_schema = "MySQL"
ORDER by (data_length + index_length) DESC;
Space occupied by #查看排名前10的表:
SELECT CONCAT (Table_schema, '. ', table_name),
CONCAT (ROUND (table_rows/1000000, 2), ' M ') table_rows,
CONCAT (ROUND (Data_length/(1024x768 * 1024x768), 2), ' G ') data_size,
CONCAT (ROUND (Index_length/(1024x768 * 1024x768), 2), ' G ') idx_size,
CONCAT (ROUND (data_length + index_length)/(1024x768 * 1024x768), 2), ' G ') total_size,
Concat (ROUND (index_length/data_length, 2) *, "%") idx_data_percent
From INFORMATION_SCHEMA. TABLES
ORDER by Data_length + index_length DESC
LIMIT 10;
Find database size and table size