Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Select Select?
Paul,
Wouldn't your solution tell you how many TABLES you have access to (ALL_TABLES) - along with the count of tables by name?
As an alternative how about:
set head off feed off pages 0
spool count_tables.sql
select 'select count(*) '||table_name||' from '||table_name||';'
from user_tables;
spool off
set head on feed on pages 9999
@count_tables
You could also use the all_tables/dba_tables views.- If you do, you should
also include owner -eg:
select 'select count(*) '||owner||'.'||table_name||' from
'||owner||'.'||table_name||';'
from all_tables;
Note that the first time "table_name" is referenced, it is used as a column alias. This is how you can tell which table the count(*) refers to. Alternatively, you could just set echo on and the SQL (and thus the table_name) to determine which table's rows are being counted at a given time.
HTH,
Mike Morgan
Compuware Corp.
Stephen originally wrote ....
> >I want to get a list of all tables and the number of records in those
> >tables for just the tables that have records in them. Something
> >like:
> >
> >select table_name,(select count(*) from table_name) nrecs
> >from all_tab_comments having nrecs > 0 order by table_name;
> >
Received on Tue Aug 05 1997 - 00:00:00 CDT
![]() |
![]() |