MySQL之SHOW TABLE STATUS命令

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: MySQL之SHOW TABLE STATUS命令 官网:https://dev.mysql.com/doc/refman/5.6/en/show-table-status.
MySQL之SHOW TABLE STATUS命令




官网: https://dev.mysql.com/doc/refman/5.6/en/show-table-status.html

13.7.5.37 SHOW TABLE STATUS Syntax

	
	
	
	
  
  
SHOW TABLE STATUS [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]

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 copy
    SELECT SUM(DATA_FREE) FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA = 'mydb' AND TABLE_NAME = 'mytable';

    For 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可以访问表信息的说明)。






     




 














 

&

           


DBA笔试面试讲解群1
DBA笔试面试讲解群2
欢迎与我联系



相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
5月前
|
存储 关系型数据库 MySQL
初步了解MySQL数据库的基本命令
初步了解MySQL数据库的基本命令
54 0
|
1月前
|
SQL 存储 关系型数据库
MySQL进阶突击系列(01)一条简单SQL搞懂MySQL架构原理 | 含实用命令参数集
本文从MySQL的架构原理出发,详细介绍其SQL查询的全过程,涵盖客户端发起SQL查询、服务端SQL接口、解析器、优化器、存储引擎及日志数据等内容。同时提供了MySQL常用的管理命令参数集,帮助读者深入了解MySQL的技术细节和优化方法。
|
3月前
|
tengine 关系型数据库 MySQL
Tengine、Nginx安装MySQL数据库命令教程
本指南详细介绍了在Linux系统上安装与配置MySQL数据库的步骤。首先通过下载并安装MySQL社区版本,接着启动MySQL服务,使用`systemctl start mysqld.service`命令。若启动失败,可尝试使用`sudo /etc/init.d/mysqld start`。利用`systemctl status mysqld.service`检查MySQL的服务状态,确保其处于运行中。通过日志文件获取初始密码,使用该密码登录数据库,并按要求更改初始密码以增强安全性。随后创建一个名为`tengine`的数据库,最后验证数据库创建是否成功以及完成整个设置流程。
|
4月前
|
SQL 关系型数据库 MySQL
MySQL 8.0报错--1118-Row size too large. The maximum row size for the used table type, not counting BLOBs,is 8126,
MySQL 8.0报错--1118-Row size too large. The maximum row size for the used table type, not counting BLOBs,is 8126,
MySQL 8.0报错--1118-Row size too large. The maximum row size for the used table type, not counting BLOBs,is 8126,
|
4月前
|
存储 关系型数据库 MySQL
MySQL基础命令及使用示例
这些基础命令构成了与MySQL数据库交互的核心,理解并掌握它们对于进行有效的数据库操作至关重要。在实际使用中,建议结合实际案例和需求来练习这些命令,以加深理解和提高效率。
94 4
|
4月前
|
存储 关系型数据库 MySQL
MySQL基础命令及使用示例
这些基础命令构成了与MySQL数据库交互的核心,理解并掌握它们对于进行有效的数据库操作至关重要。在实际使用中,建议结合实际案例和需求来练习这些命令,以加深理解和提高效率。
59 3
|
3月前
|
SQL 关系型数据库 MySQL
MySQL异常一之: You can‘t specify target table for update in FROM clause解决办法
这篇文章介绍了如何解决MySQL中“不能在FROM子句中指定更新的目标表”(You can't specify target table for update in FROM clause)的错误,提供了错误描述、需求说明、错误做法和正确的SQL写法。
1079 0
|
3月前
|
关系型数据库 MySQL 数据库
Mysql 常用命令
Mysql 常用命令
34 0
|
5月前
|
关系型数据库 MySQL 数据库
在 MySQL 中使用 Alter Table
【8月更文挑战第11天】
363 0
在 MySQL 中使用 Alter Table
|
1天前
|
关系型数据库 MySQL 数据库连接
数据库连接工具连接mysql提示:“Host ‘172.23.0.1‘ is not allowed to connect to this MySQL server“
docker-compose部署mysql8服务后,连接时提示不允许连接问题解决

热门文章

最新文章