mysql查看库、表占用存储空间大小

查看该数据库实例下所有库大小,得到的结果是以MB为单位
select table_schema,
sum(data_length)/1024/1024 as data_length,
sum(index_length)/1024/1024 
 as index_length,
sum(data_length+index_length)/1024/1024 as sum 
from information_schema.tables; 

## 查看mysql的库和索引的占用磁盘大小
select concat(truncate(sum(data_length)/1024/1024,2),'mb') as data_size,  
 concat(truncate(sum(max_data_length)/1024/1024,2),'mb') as max_data_size,   
 concat(truncate(sum(data_free)/1024/1024,2),'mb') as data_free,  
 concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size 
 from information_schema.tables where table_schema = 'parkcloud_test';

## 查看mysql库下数据表的占用磁盘大小
 select table_name, (data_length/1024/1024) as data_mb , (index_length/1024/1024)   
as index_mb, ((data_length+index_length)/1024/1024) as all_mb, table_rows   
 from information_schema.tables where table_schema = 'parkcloud_test'; 


分类: mysql

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

蜀ICP备16001794号
© 2014 - 2024 linpxing.cn All right reserved.