Calculate sizes for DataBases/Tables
Database sizes
SELECT TABLE_SCHEMA AS "DataBase Name", ROUND(SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2) AS "Size (in MB)" FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
Table sizes
SELECT TABLE_NAME, TABLE_ROWS, DATA_LENGTH, INDEX_LENGTH, ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Size (in MB)" FROM information_schema.TABLES WHERE TABLE_SCHEMA = "table_name";
Written by Sergiy Borodych
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Related Tags
#mysql
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#