Languages
[Edit]
EN

MySQL - how to check database size?

17 points
Created by:
maxsior322
347

Using MySQL querry it is possible to check database size in following way.

1. Size in bytes query example

SELECT 
  `table_schema` AS 'database_name',
  SUM(data_length + index_length) AS 'database_size' 
FROM `information_schema`.`tables `
GROUP BY `table_schema`;

Result:

Database size in bytes MySQL query example - HeidiSQL
Database size in bytes MySQL query example - HeidiSQL

2. Size in kilobytes query example

SELECT 
  `table_schema` AS 'database_name',
  ROUND(SUM(data_length + index_length) / 1024, 2) AS 'database_size' 
FROM `information_schema`.`tables`
GROUP BY `table_schema`;

Result:

Database size in kilobytes MySQL query example - HeidiSQL
Database size in kilobytes MySQL query example - HeidiSQL

3. Size in megabytes query example

SELECT 
  `table_schema` AS 'database_name',
  ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'database_size' 
FROM `information_schema`.`tables`
GROUP BY `table_schema`;

Result:

Database size in megabytes MySQL query example - HeidiSQL
Database size in megabytes MySQL query example - HeidiSQL
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MySQL - Problems

MySQL - how to check database size?
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join