MariaDB Database size, tables

MariaDB Database size, tables

Hello colleagues.

In today's short article, I want to give you some useful scripts for viewing the size of a database as an example. I will show examples that will show the size of the database in megabytes and gigabytes.

 

Article content:

  1. Size of all databases in megabytes.
  2. Size of all databases in gigabytes.
  3. The size of the tables in the database in megabytes.
  4. The size of the tables in the database in gigabytes.

 

1. Size of all databases in megabytes.

mariadb> SELECT table_schema AS "Database", 
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" 
FROM information_schema.TABLES 
GROUP BY table_schema;

mariadb_database_size


 

2. Size of all databases in gigabytes.

mariadb> SELECT table_schema AS "Database", 
ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS "Size (GB)" 
FROM information_schema.TABLES 
GROUP BY table_schema;

mariadb_database_size


 

3. The size of the tables in the database in megabytes.

mariadb> SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "test"
ORDER BY (data_length + index_length) DESC;

mariadb_database_size


 

4. The size of the tables in the database in gigabytes.

mariadb> SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024 / 1024), 2) AS "Size (GB)"
FROM information_schema.TABLES
WHERE table_schema = "test"
ORDER BY (data_length + index_length) DESC;

mariadb_database_size


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

MariaDB - ERROR Incorrect definition of table
MariaDB - ERROR Incorrect definition of table
MARIADB
Read more
Mariabackup backup - gzip compression
Mariabackup backup - gzip compression
MARIADB
Read more
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
MARIADB
Read more