Paul Nathan
Paul Nathan

Reputation: 40299

How to get the total numbers of rows stored in the MySQL database table?

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

Upvotes: 12

Views: 20080

Answers (3)

nsdb
nsdb

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

DustinB
DustinB

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

Eran Galperin
Eran Galperin

Reputation: 86805

MySQL COUNT() function

SELECT COUNT(*) FROM table

Upvotes: 28

Related Questions