Languages
[Edit]
EN

MySQL - how to check database size?

14 points
Created by:
AnnLen
9150

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

2. 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
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join