MySQL Tips and Tricks


PHP
For more information on MySQL, visit mysql.com


Database Size Query:


If you ever wanted to just grab a quick snapshot of the size of all of your databases in MySQL, this nifty little command will help you do exactly that:


SELECT table_schema 'DB name', sum(data_length + index_length) / 1024 / 1024 "DB size in MB" FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+----------------+
| DB name            | DB size in MiB |
+--------------------+----------------+
| spacewalk          |   182.23535156 |
| cpassman           |     0.70054722 |
| fisheye            |   125.92187500 |
| information_schema |     0.00781250 |
| mediawiki          |    11.06337357 |
| mysql              |     0.63244724 |
| cacti              |  4426.24525452 |
+--------------------+----------------+
7 rows in set (0.42 sec)


References: