To find the size of databases using SQL command, run the following SQL in MySQL prompt.
SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
Example

FInd disk usage by tables
To find disk usage by tables in database, run
SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as "size (MB)" FROM information_schema.TABLES WHERE table_schema = "DB_NAME_HERE" ORDER BY data_length DESC;
In the above SQL, replace DB_NAME_HERE with the actual name of the database.
Example
SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as "size (MB)" FROM information_schema.TABLES WHERE table_schema = "xogifts_db" ORDER BY data_length DESC;

See MySQL
Leave a Reply