This is part of a series of quick tips and tricks I have accumulated over the year, that I think can be useful for others.
If you have similar short tips and tricks please leave a comment.
When you start to work on a project for a new customer, a good piece of information is how many tables does the database contain and how many rows are there in each table. Or maybe you don't have access to the production database and need to send a service request to the IT operations department to get information about the production database.
Then the query below will be useful to you.
SET @DatabaseName := 'test_db'; SELECT t.TABLE_NAME, t.TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES t WHERE t.TABLE_SCHEMA = @DatabaseName AND t.TABLE_TYPE = 'BASE TABLE'