我是靠谱客的博主 酷酷大门,最近开发中收集的这篇文章主要介绍mysql查看库、表占用存储空间大小,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

http://blog.csdn.net/bzfys/article/details/55252962

1. 查看该数据库实例下所有库大小,得到的结果是以MB为单位

1 <span class="keylink">mysql</span>> select table_schema,sum(data_length)/1024/1024 as data_length,sum(index_length)/1024/1024   
2 as index_length,sum(data_length+index_length)/1024/1024 as sum from information_schema.tables;  

 

2、查看该实例下各个库大小

1 mysql>  select table_schema, sum(data_length+index_length)/1024/1024 as total_mb,   
2 sum(data_length)/1024/1024 as data_mb, sum(index_length)/1024/1024 as index_mb,   
3 count(*) as tables, curdate() as today from information_schema.tables group by table_schema order by 2 desc;  

 

3、查看单个库的大小

1 mysql> select concat(truncate(sum(data_length)/1024/1024,2),'mb') as data_size,  
2 concat(truncate(sum(max_data_length)/1024/1024,2),'mb') as max_data_size,   
3 concat(truncate(sum(data_free)/1024/1024,2),'mb') as data_free,  
4 concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size 
5  from information_schema.tables where table_schema = 'schema_name';   

 

4、查看单个表的状态

1 mysql> show table status from data_1234567890 where name = 'data_1234567890_ss' G  

 

5、查看单库下所有表的状态

1 mysql> select table_name, (data_length/1024/1024) as data_mb , (index_length/1024/1024)   
2 as index_mb, ((data_length+index_length)/1024/1024) as all_mb, table_rows   
3 from information_schema.tables where table_schema = 'schema_name';  

 

转载于:https://www.cnblogs.com/xiaojinniu425/p/11313874.html

最后

以上就是酷酷大门为你收集整理的mysql查看库、表占用存储空间大小的全部内容,希望文章能够帮你解决mysql查看库、表占用存储空间大小所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部