Skip to content

Latest commit

 

History

History
125 lines (96 loc) · 2.47 KB

show-table-status.md

File metadata and controls

125 lines (96 loc) · 2.47 KB
title summary category
SHOW TABLE STATUS
TiDB 数据库中 SHOW TABLE STATUS 的使用概况。
reference

SHOW TABLE STATUS

SHOW TABLE STATUS 语句用于显示 TiDB 中表的各种统计信息。如果显示统计信息过期,建议运行 ANALYZE TABLE

语法图

ShowStmt:

ShowStmt

ShowTargetFilterable:

ShowTargetFilterable

ShowDatabaseNameOpt:

ShowDatabaseNameOpt

示例

{{< copyable "sql" >}}

CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, c1 INT NOT NULL);
Query OK, 0 rows affected (0.11 sec)

{{< copyable "sql" >}}

INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.02 sec)
Records: 5  Duplicates: 0  Warnings: 0

{{< copyable "sql" >}}

SHOW TABLE STATUS LIKE 't1';
*************************** 1. row ***************************
           Name: t1
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 0
 Avg_row_length: 0
    Data_length: 0
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: 30001
    Create_time: 2019-04-19 08:32:06
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_bin
       Checksum:
 Create_options:
        Comment:
1 row in set (0.00 sec)

{{< copyable "sql" >}}

analyze table t1;
Query OK, 0 rows affected (0.12 sec)

{{< copyable "sql" >}}

SHOW TABLE STATUS LIKE 't1';
*************************** 1. row ***************************
           Name: t1
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 5
 Avg_row_length: 16
    Data_length: 80
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: 30001
    Create_time: 2019-04-19 08:32:06
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_bin
       Checksum:
 Create_options:
        Comment:
1 row in set (0.00 sec)

MySQL 兼容性

SHOW TABLE STATUS 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue

另请参阅