What is the MySQL query to display the 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−