2025-04-15 迁移服务器中...

mysql 查看数据库索引大小,数据库表大小

mysql 苏 demo 2911℃ 0评论

1. 查看数据库的索引空间大小

  1. -- GB为单位
  2. SELECT
  3. CONCAT(ROUND(SUM(index_length)/(1024*1024*1024), 6), ' GB') AS 'Total Index Size'
  4. FROM
  5. information_schema.TABLES
  6. WHERE
  7. table_schema LIKE 'database';
  8. -- MB为单位
  9. SELECT
  10. CONCAT(ROUND(SUM(index_length)/(1024*1024), 6), ' MB') AS 'Total Index Size'
  11. FROM
  12. information_schema.TABLES
  13. WHERE
  14. table_schema LIKE 'database';
  15.  

2. 查看数据库的数据空间大小

  1. -- GB为单位
  2. SELECT
  3. CONCAT(ROUND(SUM(data_length)/(1024*1024*1024), 6), ' GB') AS 'Total Data Size'
  4. FROM
  5. information_schema.TABLES
  6. WHERE
  7. table_schema LIKE 'database';
  8. -- MB为单位
  9. SELECT
  10. CONCAT(ROUND(SUM(data_length)/(1024*1024), 6), ' MB') AS 'Total Data Size'
  11. FROM
  12. information_schema.TABLES
  13. WHERE
  14. table_schema LIKE 'database';
  15.  

3. 查看数据库中所有表的信息

  1. SELECT
  2. CONCAT(table_schema,'.',table_name) AS 'Table Name',
  3. table_rows AS 'Number of Rows',
  4. CONCAT(ROUND(data_length/(1024*1024),6),' MB') AS 'Data Size',
  5. CONCAT(ROUND(index_length/(1024*1024),6),' MB') AS 'Index Size',
  6. CONCAT(ROUND((data_length+index_length)/(1024*1024),6),' MB') AS'Total Size'
  7. FROM
  8. information_schema.TABLES
  9. WHERE
  10. table_schema LIKE 'database';
  11.  
打赏

转载请注明:苏demo的别样人生 » mysql 查看数据库索引大小,数据库表大小

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)
收藏文章
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
评论内容为空!
还没有评论,快来抢沙发吧!
按钮 内容不能为空!
立刻说两句吧! 查看0条评论