欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

mysql数据库容量查询

发布时间:2025/5/22 数据库 163 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mysql数据库容量查询 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1、统计每张表的数据量
SELECT
*
FROM
(
select
TABLE_NAME,
concat(
round(
sum(DATA_LENGTH / 1024 / 1024 ),
7
)

) as size
from
information_schema. tables
where
table_schema = 'platform_all_edu'
GROUP BY
table_name
) t;

2、统计每张表的数据容量(数据量+索引)
select
table_name,
(
sum(DATA_LENGTH) + sum(INDEX_LENGTH)
) / 1024 / 1024 as size
from
information_schema. tables
where
table_schema = 'platform_all_edu'
GROUP BY
table_name;

3、查看数据库数据量

SELECT concat(round(sum(DATA_LENGTH / 1024 / 1024 / 1024), 2), 'G')
FROM information_schema. tables
WHERE table_schema= 'platform_all_edu' ;

转载于:https://www.cnblogs.com/invban/p/5751923.html

总结

以上是生活随笔为你收集整理的mysql数据库容量查询的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。