Home >Database >Mysql Tutorial >mysql query database size
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].
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
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'
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';
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%';
The above is the detailed content of mysql query database size. For more information, please follow other related articles on the PHP Chinese website!