Database

Get Count of Tables From MySQL Database

Now a days I have work for one application in which I have to create and drop tables dynamically and based on these new tables I have to perform such actions.

So I have to count the numbers of available tables frequently have to perform further tasks in application.

For counting the tables I have found below query which give the number of tables exists in the selected database.

[cc lang=”mysql”]
SELECT count(*) as ‘Tables’, table_schema as ‘Database’
FROM information_schema.TABLES
WHERE table_schema= “database_name”
GROUP BY table_schema
[/cc]

You just need to change the database_name with your database name and its done.

Share this if you find this helpful.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *