MySQL查看数据库大小和表大小的方法

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表大小

SELECT table_name AS "Tables",round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES

WHERE table_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;

上一篇: mycli一个基于命令行的mysql连接客户端
下一篇: 利用mysqlnd_ms实现mysql读写分离

目前还没有人评论,您发表点看法?
发表评论

评论内容 (必填):