I was looking for a way to know the sizes of my databases so I ended up using this query.
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Tamaño (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;```
I was looking for a way to know the sizes of my databases so I ended up using this query.
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Tamaño (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;```
The data_length
and index_length
are probably bytes.
The / 1024 / 1024
is divide by 1024 then divide by 1024
.
Bytes divided by 1024
gives you kilobytes.
Kilobytes divided by 1024
gives you megabytes.
Thus the result is the number of megabytes what is also suggested by the label Tamaño (MB)
(even though I don't speak this language, but the MB
is obvious).
, 2
is the second parameter to ROUND
, giving the number of decimal places to round to.