苏亚雷斯世界杯

SHOW TABLES

Syntax SHOW [FULL] TABLES [FROM db_name]

[LIKE 'pattern' | WHERE expr]

Description SHOW TABLES 列出了给定数据库中的表(直到 MariaDB 11.2.0 ,仅显示非 TEMPORARY 表)、 sequences 和 views 。

LIKE 子句(如果单独存在)指示要匹配哪些表名。可以使用 WHERE 和 LIKE 子句来选择使用更一般条件的行,如 Extended SHOW 中所述。例如,在 test 数据库中搜索表时, WHERE 和 LIKE 子句中使用的列名将是 Tables_in_test

支持 FULL 修饰符,因此 SHOW FULL TABLES 显示第二个输出列。第二列 Table_type 的值对于表是 BASE TABLE 、对于 view 是 VIEW 并且对于 sequence 是 SEQUENCE 。

您还可以使用以下方式获取此信息:

mariadb-show db_name

请参阅 mariadb-show 了解更多详细信息。

如果您没有基表或视图的权限,它不会显示在 SHOW TABLES 或 mariadb-show db_name 的输出中。

information_schema.TABLES 表以及 SHOW TABLE STATUS 语句提供了有关表的扩展信息。

Examples SHOW TABLES;

+----------------------+

| Tables_in_test |

+----------------------+

| animal_count |

| animals |

| are_the_mooses_loose |

| aria_test2 |

| t1 |

| view1 |

+----------------------+

仅显示以 a 开头的表格。

SHOW TABLES WHERE Tables_in_test LIKE 'a%';

+----------------------+

| Tables_in_test |

+----------------------+

| animal_count |

| animals |

| are_the_mooses_loose |

| aria_test2 |

+----------------------+

显示表格和表格类型:

SHOW FULL TABLES;

+----------------+------------+

| Tables_in_test | Table_type |

+----------------+------------+

| s1 | SEQUENCE |

| student | BASE TABLE |

| v1 | VIEW |

+----------------+------------+

显示临时表:<= MariaDB 11.1

CREATE TABLE t (t int(11));

CREATE TEMPORARY TABLE t (t int(11));

CREATE TEMPORARY TABLE te (t int(11));

SHOW TABLES;

+----------------+

| Tables_in_test |

+----------------+

| t |

+----------------+

从 MariaDB 11.2.0 出发:

CREATE TABLE t (t int(11));

CREATE TEMPORARY TABLE t (t int(11));

CREATE TEMPORARY TABLE te (t int(11));

SHOW TABLES;

+----------------+

| Tables_in_test |

+----------------+

| te |

| t |

| t |

+----------------+

See Also

显示表状态

information_schema.TABLES 表