table size database size in mb

Solutions on MaxInterview for table size database size in mb by the best coders in the world

showing results for - "table size database size in mb"
Ignacio
31 Sep 2017
1##############################################################
2#Database size in MB
3
4
5SELECT table_schema AS "Database", 
6ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" 
7FROM information_schema.TABLES 
8GROUP BY table_schema;
9
10##############################################################
11#Table Size in MB per database
12
13SELECT table_name AS "Table",
14ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
15FROM information_schema.TABLES
16WHERE table_schema = "database_name"
17ORDER BY (data_length + index_length) DESC;