SHOW TABLE STATUS

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

语法图

ShowTableStatusStmt:

ShowTableStatusStmt

FromOrIn:

FromOrIn

StatusTableName:

StatusTableName

示例

  1. CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, c1 INT NOT NULL);
  1. Query OK, 0 rows affected (0.11 sec)
  1. INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5);
  1. Query OK, 5 rows affected (0.02 sec)
  2. Records: 5 Duplicates: 0 Warnings: 0
  1. SHOW TABLE STATUS LIKE 't1';
  1. *************************** 1. row ***************************
  2. Name: t1
  3. Engine: InnoDB
  4. Version: 10
  5. Row_format: Compact
  6. Rows: 0
  7. Avg_row_length: 0
  8. Data_length: 0
  9. Max_data_length: 0
  10. Index_length: 0
  11. Data_free: 0
  12. Auto_increment: 30001
  13. Create_time: 2019-04-19 08:32:06
  14. Update_time: NULL
  15. Check_time: NULL
  16. Collation: utf8mb4_bin
  17. Checksum:
  18. Create_options:
  19. Comment:
  20. 1 row in set (0.00 sec)
  1. analyze table t1;
  1. Query OK, 0 rows affected (0.12 sec)
  1. SHOW TABLE STATUS LIKE 't1';
  1. *************************** 1. row ***************************
  2. Name: t1
  3. Engine: InnoDB
  4. Version: 10
  5. Row_format: Compact
  6. Rows: 5
  7. Avg_row_length: 16
  8. Data_length: 80
  9. Max_data_length: 0
  10. Index_length: 0
  11. Data_free: 0
  12. Auto_increment: 30001
  13. Create_time: 2019-04-19 08:32:06
  14. Update_time: NULL
  15. Check_time: NULL
  16. Collation: utf8mb4_bin
  17. Checksum:
  18. Create_options:
  19. Comment:
  20. 1 row in set (0.00 sec)

MySQL 兼容性

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

另请参阅