usetest;Databasechang"/> usetest;Databasechang">

Home >Database >Mysql Tutorial >Get table name using SELECT statement in MySQL?

Get table name using SELECT statement in MySQL?

PHPz
PHPzforward
2023-09-11 16:41:021660browse

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

To obtain the table name using a SELECT statement, use "information_schema.tables". Let's look at an example where we have a database with 3 tables. Syntax to get all table names with the help of SELECT statement.

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

Use database "test" and apply the above syntax to get the table name using SELECT

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

Output the names of the three tables.

+--------------------+
| TablesName         |
+--------------------+
| destination        |
| myisamtoinnodbdemo |
| originaltable      |
+--------------------+
3 rows in set (0.00 sec)

The above is the detailed content of Get table name using SELECT statement in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete