计算数据库中各个表的大小

MYSQL2013-09-18 16:23
SELECT
    table_schema AS 'Db Name',
    Round( Sum( data_length + index_length ) / 1024 / 1024, 3 ) AS 'Db Size (MB)',
    Round( Sum( data_free ) / 1024 / 1024, 3 ) AS 'Free Space (MB)'
FROM information_schema.tables
GROUP BY table_schema;

效果如下表格:

  
  
Db Name Db Size (MB) Free Space (MB)
gitlabhq_production 1.922 3276.000
information_schema 0.009 0.000
j2fashioncity 4.667 0.000
jtwo 5.168 0.000
memcached 0.067 0.000
mysql 0.679 182.000
performance_schema 0.000 0.000

原文链接: http://blog.jtwo.me/calculate-the-size-of-each-table-in-database