25 Haziran 2020 Perşembe

How to check the size of a table of a MySQL database?

This sql code is used to determine the size of a table of a MySQL database:
SELECT
  TABLE_NAME AS `Table`,
  ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024),2) AS `Size (MB)`
FROM
  information_schema.TABLES
WHERE
    TABLE_SCHEMA = "schemaName"
  AND
    TABLE_NAME = "tableName"
ORDER BY
  (DATA_LENGTH + INDEX_LENGTH)
DESC;
schemaName and tableName should be changed with real name of schema and table in your case.

The result will be seen like:
+-------------+-------------+
| Table          | Size (MB) |
+-------------+-------------+
| tableName |       267      |
+-------------+-------------+
1 row in set (0.00 sec)