Reputation: 40299
Is there a MySQL command to count the number of rows in a table, and if so, what is it?
Upvotes: 12
Views: 20080
Reputation: 110
This gives you the number of rows from a specific table name that you set:
SELECT TABLE_ROWS from information_schema.TABLES where table_name = "your_specific_table_name_here";
Upvotes: 0
Reputation: 11285
A nice way to get AN ESTIMATE of the number of rows can be via meta-data information in the information_schema tables.
Note, this is just an ESTIMATE used for query optimizations.
There may be a way to get exact # of rows from the information_schema, but I am not 100% sure if this is possible.
SELECT table_schema, table_name, table_rows FROM information_schema.tables ORDER BY table_rows DESC
Upvotes: 6