Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Get Table Names Using SELECT Statement in MySQL



To get table names using SELECT statement, use "information_schema.tables". Let us see an example, wherein we have a database that contains 3 tables. The 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';

Using database "test", and applying the above syntax to get the table names using SELECT

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

Output with the name of the three tables.

+--------------------+
| TablesName         |
+--------------------+
| destination        |
| myisamtoinnodbdemo |
| originaltable      |
+--------------------+
3 rows in set (0.00 sec)
Updated on: 2019-07-30T22:30:23+05:30

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements