How to display the size of all MySQL tables using the command line

Background

Issue the following command if you want to see in Megabytes the size of all MySQL tables from the command line:

SELECT table_name AS “Table”, ROUND(((data_length + index_length) / 1024 / 1024), 2) AS “Size (MB)” FROM information_schema.TABLES WHERE table_schema = “DATABASE_NAME” ORDER BY (data_length + index_length) DESC;

Substitute DATABASE_NAME with the name of your database.

Reference

https://www.a2hosting.co.za/kb/developer-corner/mysql/determining-the-size-of-mysql-databases-and-tables

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top