友链提交
请认真填写以下信息,谢谢!
(请填写完整的网址,例如:https://www.example.com)
(贵站展示本站链接的页面地址,一般是友链页面,填写后将自动验证友链关系有效性)
(用于抓取文章)
(用于接收通知)
侧边栏壁纸
博主头像
木因博客 博主等级

心在哪里收获就在哪里

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

目 录CONTENT

文章目录

查看MySQL占用磁盘空间大小

柳意梧情
2022-07-17 / 1 评论 / 11 点赞 / 382 阅读 / 0 字 / 正在检测是否收录...

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

评论区