Home > Database > Mysql Tutorial > body text

mysql query database size

PHPz
Release: 2020-09-27 11:12:12
Original
16775 people have browsed it

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
Copy after login

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'
Copy after login

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';
Copy after login

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%';
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!