侧边栏壁纸
博主头像
学海无涯博主等级

学无止境

  • 累计撰写 321 篇文章
  • 累计创建 80 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

MySQL查询数据库中的表占用空间的大小

利刃
2022-07-22 / 0 评论 / 0 点赞 / 6 阅读 / 1457 字
温馨提示:
本文最后更新于 2024-08-13,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
1、查看指定数据库中各表占用空间的大小  
select
table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables where table_schema='数据库名称'
order by data_length desc, index_length desc
image 2、查看各数据库占用空间的大小
select
table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables group by table_schema 
order by sum(data_length) desc, sum(index_length) desc;
  image  

2022年7月22日11:27:55

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区