Home >Database >Mysql Tutorial >How to check the database table capacity through MySQL
This article introduces the MySQL command statement to check the capacity of the database table, and provides complete query statements and examples for everyone to learn and use.
select table_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;
select table_schema as '数据库', table_name as '表名', table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tablesorder by data_length desc, index_length desc;
Example : Check the capacity of the mysql library
select table_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tableswhere table_schema='mysql';
Example: Check the capacity of each table of the mysql library
select table_schema as '数据库', table_name as '表名', table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tableswhere table_schema='mysql'order by data_length desc, index_length desc;
This article explains how to check the database table capacity through MySQL. For more related content, please pay attention to the php Chinese website.
Related recommendations:
Explanation on how to use php str_getcsv to parse a string into an array
Optimize the client Call the server interface to reduce the request data capacity
mysql order by rand() efficiency optimization method
The above is the detailed content of How to check the database table capacity through MySQL. For more information, please follow other related articles on the PHP Chinese website!