• SHOW [FULL] TABLES
    • 语法图
    • 示例
    • MySQL 兼容性
    • 另请参阅

    SHOW [FULL] TABLES

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

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

    语法图

    ShowStmt:

    ShowStmt

    ShowTargetFilterable:

    ShowTargetFilterable

    ShowDatabaseNameOpt:

    ShowDatabaseNameOpt

    示例

    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. | gc_delete_range |
    31. | gc_delete_range_done |
    32. | help_topic |
    33. | role_edges |
    34. | stats_buckets |
    35. | stats_feedback |
    36. | stats_histograms |
    37. | stats_meta |
    38. | tables_priv |
    39. | tidb |
    40. | user |
    41. +----------------------+
    42. 16 rows in set (0.00 sec)

    MySQL 兼容性

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

    另请参阅

    • CREATE TABLE
    • DROP TABLE
    • SHOW CREATE TABLE