MySQL: Show count of records in each table of a database

December 12, 2012

I recently did a dump of my database on this site and it was almost 300 megabytes! That is pretty huge for a simple personal site. Curious as to where all that data was hiding I whipped up a quick SQL query that calculates the total number of rows per table in a single database. Here is the query for your enjoyment ( and so I remember it later! )

SELECT TABLE_NAME, TABLE_ROWS 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'db21288_ben' 
ORDER BY `TABLES`.`TABLE_ROWS`  DESC