SHOW [FULL] TABLES

SHOW [FULL] TABLES 语句用于显示当前所选数据库中表和视图的列表。可选关键字 FULL 说明表的类型是 BASE TABLE 还是 VIEW

若要在不同的数据库中显示表,可使用 SHOW TABLES IN DatabaseName 语句。

语法图

ShowTablesStmt:

ShowTablesStmt

OptFull:

OptFull

ShowDatabaseNameOpt:

ShowDatabaseNameOpt

ShowLikeOrWhereOpt:

ShowLikeOrWhereOpt

示例

  1. mysql> CREATE TABLE t1 (a int);
  2. Query OK, 0 rows affected (0.12 sec)
  3. mysql> CREATE VIEW v1 AS SELECT 1;
  4. Query OK, 0 rows affected (0.10 sec)
  5. mysql> SHOW TABLES;
  6. +----------------+
  7. | Tables_in_test |
  8. +----------------+
  9. | t1 |
  10. | v1 |
  11. +----------------+
  12. 2 rows in set (0.00 sec)
  13. mysql> SHOW FULL TABLES;
  14. +----------------+------------+
  15. | Tables_in_test | Table_type |
  16. +----------------+------------+
  17. | t1 | BASE TABLE |
  18. | v1 | VIEW |
  19. +----------------+------------+
  20. 2 rows in set (0.00 sec)
  21. mysql> SHOW TABLES IN mysql;
  22. +-------------------------+
  23. | Tables_in_mysql |
  24. +-------------------------+
  25. | GLOBAL_VARIABLES |
  26. | bind_info |
  27. | columns_priv |
  28. | db |
  29. | default_roles |
  30. | expr_pushdown_blacklist |
  31. | gc_delete_range |
  32. | gc_delete_range_done |
  33. | global_priv |
  34. | help_topic |
  35. | opt_rule_blacklist |
  36. | role_edges |
  37. | stats_buckets |
  38. | stats_feedback |
  39. | stats_histograms |
  40. | stats_meta |
  41. | stats_top_n |
  42. | tables_priv |
  43. | tidb |
  44. | user |
  45. +-------------------------+
  46. 20 rows in set (0.00 sec)

MySQL 兼容性

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

另请参阅