MySQL Query to Display Number of Tables in a Database



Let’s say, here I am using the WEB database. We need to find the number of tables in the database WEB. For this, use the INFORMATION_SCHEMA.TABLES in MySQL.

Following is the query to display the number of tables −

mysql> select count(table_name) as TotalNumberOfTablesInWebDatabase
   -> from information_schema.tables
   -> where table_schema='web';

This will produce the following output −

+----------------------------------+
| TotalNumberOfTablesInWebDatabase |
+----------------------------------+
|                             1562 |
+----------------------------------+
1 row in set (0.27 sec)

To just check whether the count of records displayed above are the same or not, use the SHOW TABLES command. This command would display all the records with the count at the end as shown below−

Updated on: 2019-12-18T05:52:25+05:30

391 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements