MySQL之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


Press CTRL+C to copy

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



     






 

&

           

时间: 2024-07-28 19:37:28

MySQL之SHOW TABLE STATUS命令的相关文章

Mysql中 show table status 获取表信息的方法_Mysql

使用方法 mysql>show table status; mysql>show table status like 'esf_seller_history'\G; mysql>show table status like 'esf_%'\G; 样例: mysql>show table status like 'esf_seller_history'\G; 1.Name 表名称 2.Engine: 表的存储引擎 3.Version: 版本 4.Row_format 行格式.对于My

【资料整理】MySQL -- SHOW TABLE STATUS

要查看表的存储引擎是什么可以使用 SHOW TABLE STATUS 命令. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 mysql> show table status like 'user' \G; *************************** 1. row ***************************            Name: user          Engin

Mysql事项,视图,函数,触发器命令(详解)_Mysql

事项开启和使用 //修改表的引擎 alter table a engine=myisam; //开启事务 begin; //关闭自动提交 set autocommit=0; //扣100 update bank set money=money-100 where bid=1; //回滚,begin开始的所有sql语句操作 rollback; //开启事务 begin; //关闭自动提交 set autocommit=0; //扣100 update bank set money=money-10

mysql执行drop table 数据恢复方法

对于MySQL数据库的innodb引擎的数据库中,由于误操作删除表,或者由于sqldump自动生成语句含drop table create table语句导致数据丢失,在没有覆盖的情况下,可以实现完美恢复创建测试表 mysql> CREATE TABLE recover.`t_drop` (     ->   `messageId` varchar(30) NOT NULL,     ->   `msgContent` varchar(1000) default NULL,     -&

mysql 各版本的一些命令差异

mysql 各版本的一些命令差异: show innodb status\G mysql-5.1 show engines innodb status\G mysql-5.5   关于grant授权 mysql-5.5 的 user@'%'不包含localhost MySQL 4.1/5.0/5.1/5.5/5.6各版本的主要区别     1.4.1 增加了子查询的支持,字符集增加UTF-8,GROUP BY语句增加了ROLLUP,mysql.user表采用了更好的加密算法.     2.5.0

RDS for MySQL 错误 the table '/home/mysql/xxxx/xxxx/#tab_name' is full 的原因和处理

RDS for MySQL 错误 the table '/home/mysql/xxxx/xxxx/#tab_name' is full 的原因和处理   1. 出现这个错误信息的原因 2. 如何处理该错误信息 3. 如何判断查询是否使用内部临时表 在使用 RDS 的过程中,有时会碰到下面的出错信息: the table '/home/mysql/xxxx/xxxx/#tab_name' is full,比如: the table '/home/mysql/data3077/tmp/#sql_1

解决MySql error #1036 Table is read only 错误方法

这次网站搬家采用直接打包mysql数据库和网页文件的形式进行迁移,上传好mysql data目录里面的网站数据库至VPS上mysql存放数据库的目录里面,解压就行.我的VPS存放数据库的路径是 /usr/local/mysql/var. 上传好网站数据,解压,配置好数据库链接参数就行,网站就能正常连接上了,我本以为这已经是顺利迁移完成了,但后来操作的时候,发现只能读取数据库的内容,不能更改写入任何信息,提示#1036 – Table '* ' is read only (*号为任意表),也就是说

linux下Mysql的启动关闭的命令

 下面我来为各位介绍linux下Mysql的启动关闭的命令,有需要了解的朋友不防进入看看吧.     linux下Mysql的启动关闭(本文基于centos6.4.mysql5.7.3),mysql安装在/usr/local/mysql目录下: [root@lnmp ~]# /usr/local/mysql/bin/mysql --version /usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.7.3-m13, for Linux (x86_64)

MySQL中create table语句的基本语法是_php基础

MySQL中create table语句的基本语法是:  Create [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]  [table_options] [select_statement]  TEMPORARY:该关键字表示用create table新建的表为临时表,此表在当前会话结束后将自动消失.临时表主要被应用于存储过程中,对于目前尚不支持存储过程的MySQL,该关键字一般不用.  IF NOT EX