您如何找出MySQL数据库中数据的总大小? [英] How do you find out the total size of the data in MySQL database?

查看:116
本文介绍了您如何找出MySQL数据库中数据的总大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算MySQL中数据库的总大小?

How do you calculate the total size of the database in MySQL?

P.S.总大小,以正在使用的磁盘空间为单位.

P.S. Total size in term of how much disk space is using.

推荐答案

链接有一个非常激烈的查询...将为您提供超出您所需的......

This link has a pretty intense query... that will give you more than you need...:

SELECT s.schema_name, 
CONCAT(IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length)) /1024/1024,2),0.00)) total_size_in_MB, 
CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00)) data_used_IN_MB, 
CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00)) data_free_IN_MB, 
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/((SUM(t.data_length)+SUM(t.index_length)))*100),2),0) pct_used, 
COUNT(table_name) total_tables 
FROM INFORMATION_SCHEMA.SCHEMATA s 
LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema 
WHERE s.schema_name = 'abc' -- give your schema name 
GROUP BY s.schema_name 
ORDER BY pct_used DESC;

这篇关于您如何找出MySQL数据库中数据的总大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆