Official document address: 13.7.7.38 SHOW TABLE STATUS Statement
SHOW TABLE STATUS
[{
FROM | IN} db_name]
[LIKE 'pattern' | WHERE expr]
SHOW TABLE STATUS
SHOW TABLES
Works like the same, but provides a lot of information about each non-temporary table. You can also use the mysqlshow--status db_name
command to get this list. If there is a LIKE
clause, it indicates which table names to match. You can also use WHERE
clauses to select rows using more general conditions, as discussed in 26.55 SHOW Statement Extension .
The statement also displays information about the view.
SHOW TABLE STATUS
The output has the following columns:
- The name of the Name
table.
The storage engine of the Engine table. See Chapter 15 InnoDB storage engine and storage engine Chapter 16 to choose from . For partition tables,Engine
the names of storage engines used by all partitions are displayed.- Version
This column is not used. Since the.frm
file was deleted in MySQL 8.0, the value recorded in this column is now hard-coded10
, which is the last.frm
file version used in MySQL 5.7 . - Row_format
row storage format (Fixed
fixed,Dynamic
dynamic,Compressed
compressed,Redundant
redundant,Compact
compact). ForMyISAM
tables, itDynamic
corresponds to themyisamchk -dvv
Packed
recorded content. - Rows The
number of rows. Some storage engines, for exampleMyISAM
, store accurate counts. For other storage engines, for exampleInnoDB
, this value is only an approximation, the actual value may vary40%
to50%
. In this case, useSELECT COUNT(*)
to get an accurate count.
ForINFORMATION_SCHEMA
tables, theRows
value isNULL
.
ForInnoDB
tables, the number of rows is only a rough estimate used in SQL optimization. (The same is true forInnoDB
partition tables.) - Avg_row_length
average row length. - Data_length
respectMyISAM
,Data_length
is the length of the data file, in bytes.
ForInnoDB
,Data_length
is the approximate amount of space allocated for the clustered index, in bytes. Specifically, it is the clustered index size (in pages) multiplied by theInnoDB
page size.
For information about other storage engines, see the description at the end of this section. - Max_data_length
respectMyISAM
,Max_data_length
the maximum length of the data file. This is the total number of data bytes that can be stored in the table given the size of the data pointer used.
ForInnoDB
, the column is not used.
For information about other storage engines, see the description at the end of this section. - Index_length
respectMyISAM
,Index_length
is the length of the index file, in bytes.
ForInnoDB
,Index_length
is the approximate amount of space allocated for the non-clustered index, in bytes. Specifically, it is the non-clustered index size (in pages) multiplied by theInnoDB
page size.
For information about other storage engines, see the description at the end of this section. - Data_free
The number of bytes allocated but not used.
InnoDB
The table records the free space of the table space to which the table belongs. For tables located in a shared table space, this is the free space of the shared table space. If multiple table spaces are used, and the table has its own table space, the free space only refers to the free space of the table's own table space. Free space refers to the number of bytes in a completely free section minus the safety margin. Even if the free space is shown as0
, as long as there is no need to allocate a new section, rows can be inserted.
ForNDB Cluster
,Data_free
display the unused space allocated for disk data tables or disk fragments on the disk. (The usage of data resources in memory isData_length
reported by the column.)
For partitioned tables, this value is only an estimate and may not be absolutely correct. In this case, a more accurate way to obtain this information is to query the INFORMATION_SCHEMA
PARTITIONS
table, as shown in this example:
SELECT SUM(DATA_FREE)
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA = 'mydb'
AND TABLE_NAME = 'mytable';
For more information, see 26.21 INFORMATION_SCHEMA PARTITIONS table .
- The
nextAUTO_INCREMENT
value of Auto_increment . - Create_time
The time when the table was created. - Update_time The
time when the data file was last updated. For some storage engines, this value isNULL
. For example,InnoDB
multiple tables are stored in its system table space, and the timestamp of the data file is not applicable. Even in thefile-per-table
mode, eachInnoDB
table is in a separate.ibd
file, changing the buffer will delay the write operation to the data file, so the file modification time is different from the time of the last insertion, update, or deletion. ForMyISAM
, the timestamp of the data file is used; however, in theWindows
above, the timestamp will not be updated by updating, so the value is not accurate.
Update_time
ShowsInnoDB
the timestamp value of the last update, insert, or delete performed on an unpartitioned table. For MVCC, the timestamp value reflects theCOMMIT
time, which is considered the last update time. When the server is restarted or theInnoDB
table is deleted from the data dictionary cache, the timestamp will not be persistent. - Check_time
The time of the last check of the table. Not all storage engines are updated this time, in this case, the value is alwaysNULL
. For partitionedInnoDB
tables, itCheck_time
is alwaysNULL
.
The default collation of the Collation table. The output does not explicitly list the default character set of the table, but the collation name starts with the character set name.- Checksum
real-time checksum value (if any).
CREATE TABLE
Extra options used by Create_options .
Create_options
Display the partition status of the partition table.
Before MySQL 8.0.16, the specified clauses for tables created in the tablespace wereCreate_options
displayed . Starting from MySQL 8.0.16, if the table is encrypted, or the specified encryption is different from the mode encryption, it will display the clauses of the table space for each table file . For tables created in general tablespaces, clauses are not displayed . To identify each encrypted table file and ordinary tablespace, query the column. When creating a table with strict mode disabled, if the specified row format is not supported, the default row format of the storage engine is used. The actual row format of the table is recorded in the columns. Display the line format specified in the statement. When the storage engine of a table is changed, the table options that are not applicable to the new storage engine are retained in the table definition, so that the table and its previously defined options can be restored to the original storage engine when necessary. The reserved options can be displayed.file-per-table
ENCRYPTION
ENCRYPTION
ENCRYPTION
INNODB_TABLESPACES
ENCRYPTION
Row_format
Create_options
CREATE TABLE
Create_options
- Comment
The comment used when creating the table (or information about why MySQL cannot access the table information).
note
- For
InnoDB
tables,SHOW TABLE STATUS
no accurate statistics will be given except for the physical size reserved for the table . The number of rows is only a rough estimate used in SQL optimization. - For
NDB
tables, the output of this statement shows the appropriate values for theAvg_row_length
sumData_length
column, but theBLOB
column is not considered . - For the
NDB
table, itData_length
only contains the data in the main memory;Max_data_length
andData_free
the hard disk data recorded in the column. - For a
NDB Cluster
disk data table,Max_data_length
the space allocated for the disk portion of the disk data table or fragment is displayed. (The data resource usage in memory isData_length
reported by the column). - For
MEMORY
tables, the values ofData_length
,Max_data_length
and areIndex_length
approximate to the amount of memory actually allocated. The allocation algorithm reserves a large amount of memory to reduce the number of allocation operations. - For views, in addition to
Name
a view name,Create_time
time of creation,Comment
displayVIEW
outside,SHOW TABLE STATUS
it displayed most of the columns are0
orNULL
.
You can also INFORMATION_SCHEMA
TABLES
get table information from the table. See 26.38 INFORMATION_SCHEMA TABLES table .