信息发布→ 登录 注册 退出

在 MySQL 中使用 SELECT 语句获取表名?

发布时间:2023-09-11

点击量:

要使用 SELECT 语句获取表名称,请使用“information_schema.tables”。让我们看一个例子,其中我们有一个包含 3 个表的数据库。借助 SELECT 语句获取所有表名称的语法。

SELECT Table_name as TablesName from information_schema.tables where table_schema = 'yourDatabaseName';

使用数据库“test”,并应用上述语法使用 SELECT 获取表名

mysql> use test;
Database changed
mysql> SELECT Table_name as TablesName from information_schema.tables where table_schema = 'test';

输出三个表的名称。

+--------------------+
| TablesName         |
+--------------------+
| destination        |
| myisamtoinnodbdemo |
| originaltable      |
+--------------------+
3 rows in set (0.00 sec)
标签:# mysql  # select  # 数据库  # 让我们  # 请使用  # 要使  # 有一个  # TablesName  # table_schema  # false  # Table_name  # yourDatabaseName  # test  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!