当前位置:   article > 正文

sql命令查询mysql数据使用磁盘空间大小_sql 查看数据库磁盘内存大小

sql 查看数据库磁盘内存大小

登录mysql

mysql -uroot -p;

进入information_schema数据库

use information_schema;

查询mysql使用空间

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

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

  1. select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
  2. concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
  3. from information_schema.tables
  4. group by TABLE_SCHEMA
  5. order by data_length desc;

查询某个库所使用的磁盘空间大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='某个库';

查询某个库下表使用空间

  1. select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,
  2. concat(truncate(index_length/1024/1024,2),' MB') as index_size
  3. from information_schema.tables where TABLE_SCHEMA = '某个库'
  4. group by TABLE_NAME
  5. 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='某个表';

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/660100
推荐阅读
相关标签
  

闽ICP备14008679号