如何查询mysql数据库中哪些表的数据量最大?
数据库中有几十上百张表,那么哪些表的数据量比较大呢,总不能一个表一个表的去查询吧,在mysql中也有类似于oracle的数据字典表,只不过mysql没有oracle记录的那么多和详细,但也足够我们查询这些信息了。
在mysql的information_schema下有存储数据库基本信息的数据字典表,可以通过查询tables表来获得所需要的表相关信息。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
|mysql |
|report |
| report_result |
|test |
+--------------------+
5 rows in set (0.02 sec)
mysql> use information_schema;
Database changed
mysql> show tables;
+---------------------------------------+
|Tables_in_information_schema |
+---------------------------------------+
|CHARACTER_SETS |
|COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
|COLUMNS |
|COLUMN_PRIVILEGES |
|KEY_COLUMN_USAGE |
|PROFILING |
|ROUTINES |
|SCHEMATA |
|SCHEMA_PRIVILEGES |
|STATISTICS |
|TABLES |
|TABLE_CONSTRAINTS |
|TABLE_PRIVILEGES |
|TRIGGERS |
|USER_PRIVILEGES |
|VIEWS |
+---------------------------------------+
17 rows in set (0.00 sec)
那么我们查看一下talbes表结构信息,看看存储的具体信息
mysql> desc tables;
+-----------------+--------------+------+-----+---------+-------+
| Field |Type | Null | Key | Default |Extra |
+-----------------+--------------+------+-----+---------+-------+
| TABLE_CATALOG | varchar(512) | YES | | NULL | |
| TABLE_SCHEMA | varchar(64) | NO | | | |
| TABLE_NAME | varchar(64) | NO | | | |
| TABLE_TYPE | varchar(64) | NO | | | |
| ENGINE |varchar(64) | YES | |NULL | |
| VERSION |bigint(21) | YES | |NULL | |
| ROW_FORMAT | varchar(10) | YES | | NULL | |
| TABLE_ROWS | bigint(21) | YES | | NULL | |
| AVG_ROW_LENGTH | bigint(21) | YES | | NULL | |
| DATA_LENGTH | bigint(21) | YES | | NULL | |
| MAX_DATA_LENGTH | bigint(21) | YES | | NULL | |
| INDEX_LENGTH | bigint(21) | YES | | NULL | |
| DATA_FREE | bigint(21) |YES | | NULL | |
| AUTO_INCREMENT | bigint(21) | YES | | NULL | |
| CREATE_TIME | datetime |YES | | NULL | |
| UPDATE_TIME | datetime |YES | | NULL | |
| CHECK_TIME | datetime |YES | | NULL | |
| TABLE_COLLATION | varchar(64) | YES | |NULL | |
| CHECKSUM | bigint(21) |YES | | NULL | |
| CREATE_OPTIONS | varchar(255) | YES | |NULL | |
| TABLE_COMMENT | varchar(80) | NO | | | |
+-----------------+--------------+------+-----+---------+-------+
21 rows in set (0.00 sec)
主要存储了表的信息如表使用的引擎,表的类型等信息。我们可以通过查询table_rows属性获得哪些表数据量比较大。
mysql> select table_name,table_rows from tables order by table_rows desc limi 10;
+---------------+------------+
| table_name |table_rows |
+---------------+------------+
| task6 | 1558845 |
| task | 1554399 |
| task5 | 1539009 |
| task3 | 1532169 |
| task1 | 1531143 |
| task2 | 1531143 |
| task4 | 1521225 |
| task7 | 980865 |
我们继续深入思考,这些存储的数据是否准确,是否真实的反应了表中数据量大小?
mysql> show create table tables \G;
*************************** 1. row***************************
Table: TABLES
Create Table: CREATE TEMPORARY TABLE`TABLES` (
`TABLE_CATALOG` varchar(512) default NULL,
`TABLE_SCHEMA` varchar(64) NOT NULL default '',
`TABLE_NAME` varchar(64) NOT NULL default '',
`TABLE_TYPE` varchar(64) NOT NULL default '',
&nb
关键词:mysql
相关阅读
- 04-04ubuntu下安装了mysql 5 server忘记root密码怎么办?
- 04-04权限问题导致的MYSQL无法正常启动问题的解决办法
- 04-04Win7系统安装MySQL5.5.21图解教程
- 10-21Win2008 r2 下修改mysql data目录的方法
- 10-21MySQL修改root密码的4种方法(以windows为例)
- 03-29微软补丁KB967723造成MySQL频繁无法连接,刷新即恢复正常的解决方法 (Can not connect to MySQL server)
- 03-29Can't connect to MySQL server on 'localhost'
- 04-08Win2003+IIS6.0+php5.2.2+MySQL 5.0.41+ZendOptimizer 3.2.8 +phpMyAdmin 2.10.1环境配置安装教程图文详解
- 04-04快速让MySQL数据库服务器支持远程连接
- 02-23MYSQL数据库实用学习资料之常用命令集合
阅读本文后您有什么感想? 已有 人给出评价!
用户评论
热门评论
最新评论
相关软件
热点图文
- 01-05mysql安装图解、mysql5.6.10安装详细图文教程
- 01-04Mysql 安装问题。提示MySQL Server 5.1 -- Error 1335.
- 11-22service mysql start出错,mysql不能启动,解决mysql: unrecognized service错误
- 01-11Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2)
- 11-24wdcp修改mysql数据库root密码时提示原密码不对
- 05-13MySQL数据库INNODB 表损坏修复处理过程
- 07-18MySql5.0 Table错误:is marked as crashed and last (automatic?) repair failed
- 08-03如何查询mysql数据库中哪些表的数据量最大?
- 01-24MYSQL-Front中文版使用图文教程
- 04-04Win7系统安装MySQL5.5.21图解教程