在 MySQL 中使用 SELECT 语句获取表名?
要使用 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)
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP