诺亚方舟

沉淀

show table status

show table status 的功能,实际上查的是information_schema.tables这个表,对于myisam是实时正确的,对于innodb则大部分字段是估值。下面copy来自手册的解释:

1
2
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 LIKEclause, 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 22.33, “Extensions to SHOW Statements”.

This statement also displays information about views.

SHOW TABLE STATUS output has the following columns:

  • NameThe name of the table.
  • EngineThe storage engine for the table. See Chapter 16, Alternative Storage Engines.
  • VersionThe version number of the table’s .frm file.
  • Row_formatThe row-storage format (FixedDynamicCompressedRedundantCompact). For MyISAM tables, (Dynamic corresponds to what myisamchk -dvv reports as Packed. The format of InnoDB tables is reported as Redundant or Compact. For the Barracuda file format of the InnoDB Plugin, the format may be Compressed or Dynamic.
  • RowsThe 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_lengthThe average row length.
  • Data_lengthFor MyISAMData_length is the length of the data file, in bytes.For InnoDBData_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_lengthFor MyISAMMax_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_lengthFor MyISAMIndex_length is the length of the index file, in bytes.For InnoDBIndex_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 InnoDBpage size.

    Refer to the notes at the end of this section for information regarding other storage engines.

  • Data_freeThe 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 theINFORMATION_SCHEMA.PARTITIONS table, as shown in this example:

1
2
3
4
SELECT    SUM(DATA_FREE)
    FROM  INFORMATION_SCHEMA.PARTITIONS
    WHERE TABLE_SCHEMA = 'mydb'
    AND   TABLE_NAME   = 'mytable';

 

  • For more information, see Section 22.15, “The INFORMATION_SCHEMA PARTITIONS Table”.
  • Auto_incrementThe next AUTO_INCREMENT value.
  • Create_timeWhen the table was created.
  • Update_timeWhen 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_timeWhen the table was last checked. Not all storage engines update this time, in which case the value is always NULL.
  • CollationThe table’s character set and collation.
  • ChecksumThe live checksum value (if any).
  • Create_optionsExtra 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.
  • CommentThe comment used when creating the table (or information as to why MySQL could not access the table information).

Notes:

  • For MEMORY tables, the Data_lengthMax_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 views, all the fields displayed by SHOW TABLE STATUS are NULL except that Name indicates the view name and Comment says view.

手册地址:SHOW TABLE STATUS Syntax

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>