Friday, 13 November 2020

SQL: Get table names of a particular database

Following command is used to get all table names of a particular database.

 

SELECT TABLE_NAME

FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA={DATABASE_NAME};

 

Example

mysql> SELECT TABLE_NAME 
    -> FROM INFORMATION_SCHEMA.TABLES
    -> WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='demo';
+---------------+
| TABLE_NAME    |
+---------------+
| customer      |
| employee      |
| test_customer |
+---------------+
3 rows in set (0.00 sec)

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment