In this article, we will learn how to how to get a list of all the table names of a particular database by using a query in MySQL.
There are two ways to find all table names present in a specific database by using the following Show tables or metadata tables commands in MySQL:
SHOW TABLES
statement is used to get a list of all the tables present in the specific database. It returns only table name from a specific database.
USE Your_DatabaseName;
SHOW TABLES;
The SHOW TABLES
statement allows you to show if a table is a base table or a view. To include the table type in the result, you use the following form of the SHOW TABLES
statement.
USE Your_DatabaseName;
SHOW FULL TABLES;
Another way to get all the table name of a specific database by using the system view INFORMATION_SCHEMA.TABLES
. This returns one row for each table or view in the specific database.
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = Your_DatabaseName;
I hope this article will help you to understand how to get a list of all the table names of a particular database by using a query in MySQL
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments