Home > Database > Mysql Tutorial > body text

MySQL View database table capacity size

jacklove
Release: 2019-02-23 15:34:37
Original
22458 people have browsed it

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.

Recommended related mysql video tutorials: "mysql tutorial"

1. View the capacity of all databases

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

2. Check the capacity of each table in all databases

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

3. Check the capacity of the specified database

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

MySQL View database table capacity size
4. Check the capacity of each table in the specified database

Example: Check the capacity of each table in 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;
Copy after login

MySQL View database table capacity size

This article It explains how to check the database table capacity in MySQL. For more related knowledge, please pay attention to the PHP Chinese website.

Related recommendations:

Detailed explanation of a singleton mode Mysql operation class encapsulated by PHP

##Interpretation of PHP's PDO connection database Related content

#How to recursively obtain the value of a specified key in an array through PHP code

The above is the detailed content of MySQL View database table capacity 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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template