侧边栏壁纸
博主头像
liuyiwuqing博主等级

心在哪里收获就在哪里

  • 累计撰写 22 篇文章
  • 累计创建 24 个标签
  • 累计收到 27 条评论

目 录CONTENT

文章目录

查看MySQL占用磁盘空间大小

liuyiwuqing
2022-07-17 / 1 评论 / 11 点赞 / 445 阅读 / 225 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-11-23,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
广告 广告

1、查看所有库:

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;

2、查看单个库:

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 ='databasename';

3、查看单库下所有表:

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 = 'databasename' group by TABLE_NAME order by data_length desc;

4、查看单库下单表:

SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM TABLES 
WHERE TABLE_SCHEMA='数据库名' AND TABLE_NAME='表名'
11
广告 广告

评论区