How to count the rows of all tables under a given schema??
431096Oct 13 2004 — edited Oct 13 2004I 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!!!