tags:

views:

166

answers:

3

Is there a way to query the DB to find out how many rows there are in all the tables

ie

table1 1234
table2 222
table3 7888

Hope you can advise

+1  A: 

SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES

Nir
+2  A: 
SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables` WHERE `table_schema` = 'YOUR_DB_NAME';
great_llama
Fantastic Thank you
Lee
As far as I know, row count is not stored for InnoDB tables. This query can give an approximation at most.
Álvaro G. Vicario
+1  A: 
select sum(cnt) from
(
select count(*) as cnt from table1
union
select count(*) as cnt from table2
union 
select count(*) as cnt from table3 
)t1
a1ex07