MySQL: Get database and table sizes

Get the size in GB of each database in mysql.

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

Get database status in mysql.

SHOW TABLE STATUS FROM my_finance; 

Get all table sizes of a database schema in mysql.

SELECT TABLE_NAME AS "Tables", 
round(((data_length + index_length) / 1024 / 1024), 2) AS "Table size in MB" 
FROM information_schema.TABLES 
WHERE table_schema = "my_finance"
ORDER BY (data_length + index_length) DESC;

Search within Codexpedia

Custom Search

Search the entire web

Custom Search