Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many rows in MySQL database table?

Tags:

mysql

Is there a MySQL command to get a count on the number of rows in a table, and if so, what is it?

like image 215
Paul Nathan Avatar asked Jan 11 '09 22:01

Paul Nathan


2 Answers

MySQL COUNT() function

SELECT COUNT(*) FROM table
like image 177
Eran Galperin Avatar answered Oct 07 '22 11:10

Eran Galperin


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
like image 27
DustinB Avatar answered Oct 07 '22 12:10

DustinB