Saturday, July 12, 2008

To view all table rows count in a stored procedure

set head on
set echo on
declare
a number;
str varchar2(500);
begin
for i in (select table_name from user_tables) loop
str:='select count(*) from ' || i.table_name;
execute immediate str into a;
dbms_output.put_line(i.table_name || ':' || a);
end loop;
end;
/

Note:
table name can not be dynamic in select c1,c2..from . Use the above approach instead.

Sphere: Related Content

0 comments: