Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL to find out user table which count > 0!
You could write a PL/SQL program that uses the dbms_sql package to
dynamically submit queries fo rowcount for each table.
In pseudo code...
declare cursor c1 is select * from user_tables;
sSQL varchar2(255);
hCursor long; -- a cursor handle; see the package for exact req's
begin
for each rec in c1 loop
sSQL := 'select count(*) from ' || rec.table_name; --here you'd get a cursor handle, prepare, execute, fetch and close within the lop -- then you could insert to a temp table ordbms_output.put_line(rec.table_name || ' count:' || ....
end loop;
alternatively, you could just use the dbms package that analyze's the schema to update the table stat's and then just select the count from the dba table.
Yeung Man wrote in message <77mois$ik1_at_news.hk.linkage.net>...
>Hi,
>
> I want to find out all user tables in our application system with
>rowcount > 0. I know I can do with the analysis and the query the dict.
But,
>can I just use SQL to find them out? TIA.
>
>Best Regards,
>Man
>
>yngm_at_chowsangsang.com
>
>
Received on Fri Jan 15 1999 - 01:22:30 CST