The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Friday, 12 August 2011

List MySql database size with a query

The query:

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

The mysql console:

mysql> SELECT table_schema "Data Base Name",
-> sum( data_length + index_length ) / 1024 /
-> 1024 "Data Base Size in MB",
-> sum( data_free )/ 1024 / 1024 "Free Space in MB"
-> FROM information_schema.TABLES
-> GROUP BY table_schema ;
+--------------------+----------------------+------------------+
| Data Base Name | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| information_schema | 0.00878906 | 0.00000000 |
| mysql | 0.61361027 | 0.00000000 |
| performance_schema | 0.00000000 | 0.00000000 |
| test | 0.01562500 | 10.00000000 |
+--------------------+----------------------+------------------+
4 rows in set (0.00 sec)

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home