官网: https://dev.mysql.com/doc/refman/5.6/en/show-table-status.html
SHOW TABLE STATUS works likes SHOW TABLES, but provides a lot of information about each non-TEMPORARY table. You can also get this list using the mysqlshow --status db_name command. The LIKE clause, if present, indicates which table names to match. The WHERE clause can be given to select rows using more general conditions, as discussed in Section 21.33, “Extensions to SHOW Statements”.
This statement also displays information about views.
SHOW TABLE STATUS output has the following columns:
-
Name
The name of the table.
-
Engine
The storage engine for the table. See Chapter 15, Alternative Storage Engines.
-
Version
The version number of the table's .frm file.
-
Row_format
The row-storage format (Fixed, Dynamic, Compressed, Redundant, Compact). For MyISAM tables, Dynamic corresponds to what myisamchk -dvv reports as Packed. InnoDB table format is either Redundant or Compact when using the Antelope file format, or Compressed or Dynamic when using the Barracuda file format.
-
Rows
The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40 to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count.
The Rows value is NULL for tables in the INFORMATION_SCHEMA database.
-
Avg_row_length
The average row length.
Refer to the notes at the end of this section for related information.
-
Data_length
For MyISAM, Data_length is the length of the data file, in bytes.
For InnoDB, Data_length is the approximate amount of memory allocated for the clustered index, in bytes. Specifically, it is the clustered index size, in pages, multiplied by the InnoDB page size.
Refer to the notes at the end of this section for information regarding other storage engines.
-
Max_data_length
For MyISAM, Max_data_length is maximum length of the data file. This is the total number of bytes of data that can be stored in the table, given the data pointer size used.
Unused for InnoDB.
Refer to the notes at the end of this section for information regarding other storage engines.
-
Index_length
For MyISAM, Index_length is the length of the index file, in bytes.
For InnoDB, Index_length is the approximate amount of memory allocated for non-clustered indexes, in bytes. Specifically, it is the sum of non-clustered index sizes, in pages, multiplied by the InnoDB page size.
Refer to the notes at the end of this section for information regarding other storage engines.
-
Data_free
The number of allocated but unused bytes.
This information is also shown for InnoDB tables (previously, it was in the Comment value). InnoDB tables report the free space of the tablespace to which the table belongs. For a table located in the shared tablespace, this is the free space of the shared tablespace. If you are using multiple tablespaces and the table has its own tablespace, the free space is for only that table. Free space means the number of bytes in completely free extents minus a safety margin. Even if free space displays as 0, it may be possible to insert rows as long as new extents need not be allocated.
For partitioned tables, this value is only an estimate and may not be absolutely correct. A more accurate method of obtaining this information in such cases is to query the INFORMATION_SCHEMA.PARTITIONS table, as shown in this example:
Press CTRL+C to copyFor more information, see Section 21.13, “The INFORMATION_SCHEMA PARTITIONS Table”.
-
Auto_increment
The next AUTO_INCREMENT value.
-
Create_time
When the table was created.
-
Update_time
When the data file was last updated. For some storage engines, this value is NULL. For example, InnoDB stores multiple tables in its system tablespace and the data file timestamp does not apply. Even with file-per-table mode with each InnoDB table in a separate .ibd file, change buffering can delay the write to the data file, so the file modification time is different from the time of the last insert, update, or delete. For MyISAM, the data file timestamp is used; however, on Windows the timestamp is not updated by updates so the value is inaccurate.
-
Check_time
When the table was last checked. Not all storage engines update this time, in which case the value is always NULL.
-
Collation
The table's character set and collation.
-
Checksum
The live checksum value (if any).
-
Create_options
Extra options used with CREATE TABLE. The original options supplied when CREATE TABLE is called are retained and the options reported here may differ from the active table settings and options.
-
Comment
The comment used when creating the table (or information as to why MySQL could not access the table information).
Notes:
-
For MEMORY tables, the Data_length, Max_data_length, and Index_length values approximate the actual amount of allocated memory. The allocation algorithm reserves memory in large amounts to reduce the number of allocation operations.
-
For NDB tables, the output of this statement shows appropriate values for the Avg_row_length and Data_length columns, with the exception that BLOB columns are not taken into account
-
For views, all the fields displayed by SHOW TABLE STATUS are NULL except that Name indicates the view name and Comment says view.
[FROM db_name] 可选,表示查询哪个数据库下面的表信息。
[LIKE 'pattern'] 可选,表示查询哪些具体的表名。
2、例如
(1)、show table status from db_name
查询db_name 数据库里所有表的信息
(2)、show table status from db_name like 'esf_seller_history'\G;
查询db_name 里 esf_seller_history 表的信息
(3)、show table status from db_name LIKE 'uc%'
查询db_name 数据库里表名以uc开头的表的信息
show table status 获取表的信息
show table status like 'tableName' \G
1.Name
表名称
2.Engine:
表的存储引擎
3.Version:
版本
4.Row_format
行格式。对于MyISAM引擎,这可能是Dynamic,Fixed或Compressed。动态行的行长度可变,例如Varchar或Blob类型字段。固定行是指行长度不变,例如Char和Integer类型字段。
5. Rows
表中的行数。对于非事务性表,这个值是精确的,对于事务性引擎,这个值通常是估算的。
6.Avg_row_length
平均每行包括的字节数
7.Data_length
整个表的数据量(单位:字节)
8.Max_data_length
表可以容纳的最大数据量
9.Index_length
索引占用磁盘的空间大小
10.Data_free
对于MyISAM引擎,标识已分配,但现在未使用的空间,并且包含了已被删除行的空间。
11.Auto_increment
下一个Auto_increment的值
12.Create_time
表的创建时间
13.Update_time
表的最近更新时间
14.Check_time
使用 check table 或myisamchk工具检查表的最近时间
15.Collation
表的默认字符集和字符排序规则
16.Checksum
如果启用,则对整个表的内容计算时的校验和
17.Create_options
指表创建时的其他所有选项
18.Comment
包含了其他额外信息,对于MyISAM引擎,包含了注释徐标新,如果表使用的是innodb引擎 ,将现实表的剩余空间。如果是一个视图,注释里面包含了VIEW字样。
SHOW TABLE STATUS会返回以下字段:
Name | 表的名称 |
Engine | 表的存储引擎。在MySQL 4.1.2之前,本值被标记为Type。 |
Version | 表的.frm文件的版本号 |
Row_format | 行存储格式(Fixed, Dynamic, Compressed, Redundant, Compact)。InnoDB表的格式被报告为Redundant或Compact |
Rows | 行的数目。部分存储引擎,如MyISAM,存储精确的数目。对于其它存储引擎,比如InnoDB,本值是一个大约的数,与实际值相差可达40到50%。在这些情况下,使用SELECT COUNT(*)来获得准确的数目。对于在INFORMATION_SCHEMA数据库中的表,Rows值为NULL。 |
Avg_row_length | 平均的行长度。
|
Data_length | 数据文件的长度。 |
Max_data_length | 数据文件的最大长度。如果给定了数据指针的大小,这是可以被存储在表中的数据的字节总数。
|
Index_length | 索引文件的长度。 |
Data_free | 被整序,但是未使用的字节的数目。 |
Auto_increment | 下一个AUTO_INCREMENT值。 |
Create_time | 表创建时间。 |
Update_time | 什么时候数据文件被最后一次更新 |
Check_time | 什么时候表被最后一次检查。不是所有的存储引擎此时都更新,在此情况下,值为NULL。 |
Collation | 表的字符集和整序。 |
Checksum | 活性校验和值。 |
Create_options | 和CREATE TABLE同时使用的额外选项。 |
Comment | 创建表时使用的评注(或者有关为什么MySQL可以访问表信息的说明)。 |
给MYSQL的SHOW TABLE STATUS结果做过滤
MySQL中可以使用 show table status 查看表的状态,但是不能像select 语句选出结果那样做结果过滤。
有没有办法像select语句那样过滤呢,答案是有的,就是从information_schema库的tables表中查询。
如下是模仿show table status 的SQL:
SELECT table_name,Engine,Version,Row_format,table_rows,Avg_row_length, Data_length,Max_data_length,Index_length,Data_free,Auto_increment, Create_time,Update_time,Check_time,table_collation,Checksum, Create_options,table_comment FROM information_schema.tables WHERE Table_Schema='MyDataBaseName';
注意替换MyDataBaseName的名称为自己的库名称,这样就可以方便在Where部分添加各种条件过滤了。
About Me
.............................................................................................................................................
● 本文整理自网络,若有侵权请联系小麦苗删除
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址:http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群号:230161599(满)、618766405
● 微信群:可加我微信,我拉大家进群,非诚勿扰
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-08-01 09:00 ~ 2017-08-31 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典),学习最实用的数据库技术。
![]()
小麦苗的微信公众号 小麦苗的DBA宝典QQ群1 小麦苗的DBA宝典QQ群2 小麦苗的微店
.............................................................................................................................................
![]()
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-2144284/,如需转载,请注明出处,否则将追究法律责任。