Home > Database > Mysql Tutorial > 统计MySQL数据表大小_MySQL

统计MySQL数据表大小_MySQL

WBOY
Release: 2016-06-01 13:18:22
Original
1162 people have browsed it

bitsCN.com

有时候需要查询MySQL数据库中各个表大小,该如何操作呢?

MySQL中有一个名为 information_schema 的数据库,在该库中有一个 TABLES 表,这个表主要字段分别是:

TABLE_SCHEMA : 数据库名
TABLE_NAME:表名
ENGINE:所使用的存储引擎
TABLES_ROWS:记录数
DATA_LENGTH:数据大小
INDEX_LENGTH:索引大小

其他字段请参考MySQL的手册。

use information_schema;SELECT    TABLE_NAME,	(DATA_LENGTH/1024/1024) as DataM ,	(INDEX_LENGTH/1024/1024) as IndexM, 	((DATA_LENGTH+INDEX_LENGTH)/1024/1024) as AllM,	TABLE_ROWSFROM    TABLESWHERE    TABLE_SCHEMA = 'db_ip';
Copy after login
bitsCN.com
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