Home>Article>Database> How to check the size of a table in mysql

How to check the size of a table in mysql

coldplay.xixi
coldplay.xixi Original
2020-08-24 16:16:44 8876browse

mysql How to check the size of the table: 1. Check the capacity of each table in all databases, the code is [truncate(data_length/1024/1024, 2) as 'data capacity (MB)']; 2. Check the specified The capacity of each database table.

How to check the size of a table in mysql

mysql method to view the size of the table:

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.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc;

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.tables order by data_length desc, index_length desc;

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.tables where table_schema='mysql';

4. Check the capacity of each table in the specified database

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.tables where table_schema='mysql' order by data_length desc, index_length desc;

Related learning recommendations:mysql tutorial

The above is the detailed content of How to check the size of a table in mysql. 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