工作中遇到 需要统计MySQL数据库中表的存储内存大小,这篇博客亲测可用,因此转载以做收藏,本文转自
https://blog.csdn.net/chen3888015/article/details/79665568
查询各个数据库占用空间大小
select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
-> concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
-> from information_schema.tables
-> group by TABLE_SCHEMA
-> order by data_length desc;
查询某个数据库内各个表的容量大小
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,
-> concat(truncate(index_length/1024/1024,2),' MB') as index_size
-> from information_schema.tables where TABLE_SCHEMA = '数据库名字'
-> group by TABLE_NAME
-> order by data_length desc;
单查询某个表占用空间大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='数据库名字' and table_name='表名字';
http://www.jb51.net/article/24392.htm
https://blog.csdn.net/fuckomg/article/details/59172784
https://www.cnblogs.com/ma6174/archive/2012/12/09/2810488.html
http://lib.csdn.net/article/mysql/5066
https://www.oschina.net/question/190338_66728
https://blog.csdn.net/zy_281870667/article/details/51735153
https://blog.csdn.net/zhongwumao/article/details/72821411
https://blog.csdn.net/wangyueting415/article/details/65033543
https://segmentfault.com/a/1190000006158186
https://blog.csdn.net/wangyueting415/article/details/65033543