how to get mysql table size in GB

后端 未结 6 609
终归单人心
终归单人心 2020-12-09 04:43

Just ended up with calculating the size of MySQL table in GB with the following query.

SELECT (data_length+index_length)/power(1024,3) tablesize_gb FR

6条回答
  •  天命终不由人
    2020-12-09 05:10

    SELECT 
         table_name AS `Table`, 
         round(((data_length + index_length) / 1024 / 1024 ), 2) as `Size in MB`,
         round((AVG_ROW_LENGTH / 1024), 2) as `Avg row size in KB`
    FROM information_schema.TABLES WHERE table_schema = 'your_db_name'
    ORDER BY `Size in MB` DESC
    

提交回复
热议问题