Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exact count of all rows in MySQL database [duplicate]

I'm currently using the script

SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'Tables';

However, it's not accurate, because the engine used by my MySQL tables is InnoDB (I only realised this could be an issue now, be these databases have existed for a while).

Is there any way to get an exact count of every row in every table of a database with MySQL?

Cheers.

like image 843
Connor Deckers Avatar asked Jun 06 '12 10:06

Connor Deckers


1 Answers

I think the only accurate (and slower) way is to do for every single table:

SELECT COUNT(*) FROM Table
like image 74
jkrcma Avatar answered Oct 22 '22 21:10

jkrcma