return size of tables in mysql 1

return size of tables in mysql

SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;

Here is what the above code is Doing:
1. We’re selecting the database name, table name, and the size of the table in MB.
2. We’re ordering the results by the size of the table in MB.

Let’s run the code and see what we get:

Similar Posts