Help with counting records in atable
I have created around 40 tables in a database. Is there a way I can count total records in all the tables at a time instead of doing table by table?
Your help is appreciated.
You can analyze those tables and select num_rows from dba_tables.
That however will return the number of rows at the moment when the tables are analyzed, not the actual number of rows.
Not to mention that the number might be inconsistent, since the number of rows of table 1 will be counted at one moment and in table 2 in another
select (select count(*) from employees)+(select count(*) from departments
That is doing again counting table by table, but the result is aggregated by the outer select
One empty table will spoil that for you -- use NVL(count(*),0).
Originally Posted by Bore
you could also ...
select count(*) from
select null from employees
select null from departments
Only 40 tables? If there's not too many rows (ie) not 100,000,000 then do a quick Export and the logfile will show how many rows in each table.
Originally Posted by ujjwala
count(*) from empty table is still 0 not null. It is good to think about nulls in arithmetic expressions but no need of nvl here
Click Here to Expand Forum to Full Width