Home > Database > Mysql Tutorial > body text

Get table name using SELECT statement in MySQL?

PHPz
Release: 2023-09-11 16:41:02
forward
1580 people have browsed it

在 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';
Copy after login

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';
Copy after login

Output the names of the three tables.

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

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!