Table Size in SQL

Here’s a quick way to determine which table has the most data in it:

SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
WHERE table_schema = "INSERT-DB-NAME-HERE";

Replace INSERT-DB-NAME-HERE with the database name of your choosing, but other than that, it should display all tables in a database and list their relative sizes.

You can also sort by Size in MB to narrow your search quicker. This will list them alphabetically.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *