mysql_database_sizes
This is an old revision of the document!
File size of a specific db
Note: replace “Data Base Name” with the db name.
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 = "$DATABASE_NAME"
Size of ALL databases
Note: You do not need to change the 'Database Name' entry
SELECT table_schema "Database 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 ;
Size of a table in a db
Note: You will need to replace DATABASE_NAME and TABLE_NAME.
SELECT table_name AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "$DATABASE_NAME"
AND table_name = "$TABLE_NAME";
mysql_database_sizes.1427740213.txt.gz · Last modified: 2024/05/23 07:26 (external edit)
