--查询SCOTT用户中所有表的记录数
declare
v_count number;
query varchar2(4000);
begin
for i in (select table_name
from all_tables
where owner = 'SCOTT'
order by 1) loop
query := 'select count(*) from "' || i.table_name || '"';
execute immediate query
into v_count;
dbms_output.put_line(rpad(i.table_name, 35, ' ') || '-----' || v_count);
end loop;
end;
--查看分区表的行数
declare
v_count number;
query varchar2(4000);
begin
for i in (select table_name,partition_name
from user_tab_partitions
where table_name='DDM_TRANSACTION_LOG'
order by 1) loop
query := 'select count(*) from ' || i.table_name || ' partition(' || i.partition_name || ')' || '';
execute immediate query
into v_count;
dbms_output.put_line(rpad(i.partition_name, 35, ' ') || '-----' || v_count);
end loop;
end;