加入收藏 | 设为首页 | 会员中心 | 我要投稿 航空爱好网 (https://www.ikongjun.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

找出mysql最占硬盘的数据

发布时间:2022-07-03 12:29:32 所属栏目:MySql教程 来源:互联网
导读:查看每个库的使用情况 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_
  查看每个库的使用情况
 
  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;
 
  查看每个表的使用情况
 
  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
 
  order by data_length desc, index_length desc;

(编辑:航空爱好网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!