Tuesday, July 15, 2014

Get size of database

You can get the size of a specific database by running this command:

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
WHERE table_schema = "";

If you want to show  the size of all databases on a server, then use this command:

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 ;

No comments: