Home  >  Article  >  Database  >  mysql query database size

mysql query database size

PHPz
PHPzOriginal
2020-09-25 16:12:0016968browse

Mysql method to query the size of the database: 1. Query the size of the entire database, the code is [select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')]; 2. To query the size of a certain library, the code is [from informati].

mysql query database size

Related learning recommendations: mysql database

Mysql method to query the size of the database:

1. Query the entire mysql database and the size of the entire library; the unit is converted to MB.

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from information_schema.TABLES

mysql query database size

2. Query the mysql database and the size of a certain library;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
  from information_schema.TABLES
 where table_schema = 'testdb'

mysql query database size

3. Check the size of a certain library The size of each table;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
  from information_schema.TABLES
 where table_schema = 'testdb'
   and table_name = 'test_a';

mysql query database size

4. View all storage sizes of tables starting with test in the mysql library;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
  from information_schema.TABLES
 where table_schema = 'testdb'
   and table_name like 'test%';

mysql query database size

The above is the detailed content of mysql query database size. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:mysql group query by timeNext article:mysql group query by time