Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to count the rows of all tables under a given schema??

431096Oct 13 2004 — edited Oct 13 2004
I have done this using the following PLSQL procedure for the currently logged in schema.

create or replace procedure getRows is
tabcount number := 0;
totcount number := 0;
tabname varchar2(30);
cursor tab_cur is select tname from tab ;
begin
dbms_output.put_line ( 'Start of proc' );
open tab_cur;
loop
fetch tab_cur into tabname;
exit when tab_cur%NOTFOUND;
EXECUTE IMMEDIATE 'select count(*) from '|| tabname into tabcount;
totcount := totcount + tabcount;
dbms_output.put_line ( to_char( tabcount , 999999 ) );
end loop;
dbms_output.put_line ( to_char( totcount , 999999 ) );
close tab_cur;
dbms_output.put_line ( 'End of proc' );
end;
/

I need to know whether it can be done with a single SQL statement without any PL/SQL involved in it.

The problem that I face is that can we use bind variables in the FROM clause of the SQL SELECT Statements ??

It would be very helpful if somebody could help me out of this problem!!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2004
Added on Oct 13 2004
5 comments
521 views