Mysql空间查询

查询所有数据库占用空间大小

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,table_rows,data_length+index_length,
concat(round((data_length+index_length)/1024/1024,2),'MB') 
data from information_schema.tables where table_schema='你要查询的库'

查询整个库里面所有表的信息

select * from information_schema.tables 
where table_schema='你要查询的库';

查询某个数据库内各个表的容量大小

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;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ORA-00001: 违反唯一约束条件 (.) 错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常。 O...
    我想起个好名字阅读 5,450评论 0 9
  • --- layout: post title: "如果有人问你关系型数据库的原理,叫他看这篇文章(转)" date...
    蓝坠星阅读 824评论 0 3
  • 1xx:临时响应,表示临时响应并需要请求者继续执行操作的状态代码2xx:成功,表示成功处理了请求的状态代码3xx:...
    ShenYj阅读 254评论 0 1
  • 文:艾蓝 深秋,叶落时节。图书室侧边那条偏僻幽静小道上的梧桐树开始纷纷扬扬。 梧桐叶的坠落是一段优美的华尔兹,一圈...
    艾蓝8081阅读 337评论 0 1
  • Android系统提供了一些通用服务,比如音乐打电话发短信,WIFI,定位,输入法,传感器等。应用程序与这些通用服...
    Gooooood阅读 1,091评论 0 1