MySQL查看数据库大小和表大小的方法
其实很简单,就不多说了,基本上看得懂代码都明白
查看MySQL数据库大小
SELECT table_schema “Database Name”,
sum( data_length + index_length ) / 1024 / 1024
“Database Size in MB” FROM information_schema.TABLES GROUP BY table_schema;
查看MySQL表大小
SELECTtable_nameAS"Tables",round(((data_length+index_length)/1024/1024),2)"Size in MB"
FROMinformation_schema.TABLES
WHEREtable_schema="www_jincon_com"
ORDER BY(data_length+index_length)DESC;
当然如果你想找出前10的也是可以的
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;