How to check the size of a table in mysql

coldplay.xixi
Release: 2020-08-24 16:16:44
Original
8849 people have browsed it

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

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

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!

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
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!