【原创】MySQL如何查看索引和表数据大小?

blogdaren 2017-04-06 抢沙发 1022人次
    >> 假定数据库名称为: shop  <<
1. 查看数据大小:

SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024), 2), ' M')  AS 'Total Data Size'  
FROM information_schema.TABLES WHERE table_schema = 'shop'; 

2. 查看索引大小:

    SELECT  CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' M')  AS 'Total Index Size'  
    FROM information_schema.TABLES  WHERE table_schema = 'shop';  

3. 综合起来查看总大小:

SELECT  
  CONCAT(table_schema,'.',table_name) AS 'Table Name',  
  table_rows AS 'Number of Rows',  
  CONCAT(ROUND(data_length/(1024*1024), 2), ' M') AS 'Data Size',  
  CONCAT(ROUND(index_length/(1024*1024), 2), ' M') AS 'Index Size',  
  CONCAT(ROUND((data_length+index_length)/(1024*1024), 2), ' M') AS 'Total'  
FROM information_schema.TABLES  
WHERE table_schema = 'shop';  

版权声明:除非注明,本文由( blogdaren )原创,转载请保留文章出处。

本文链接:【原创】MySQL如何查看索引和表数据大小?

发表评论:

您的昵称:
电子邮件:
个人主页: