欢迎大家访问博主的博客新家:IT博客达人网 (http://www.blogdaren.com)[耶]
  • 微信微信

MySQL如何查看索引和表数据大小?

manon 2017-4-6 19:46 Mysql 抢沙发 434人打酱油 打开侧边栏| 关闭侧边栏
    >> 假定数据库名称为: 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';  
正文部分到此结束

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

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

继续浏览:木有标签

常用的缓存淘汰算法:即缓存失效策略(FIFO 、LRU、LFU三种算法的区别)
TCP协议和UDP协议有什么区别?

发表评论

看看右边的头像对不对?→_→