Wednesday, May 25, 2011

Number of Rows per Partition in a Table

Simple and handy anonymous block to share that provides the total number of rows per partition in a given table:

___________________________________________________________________
set serveroutput on size unlimited
set echo off
set verify off
declare
cursor c1 is
select table_name,partition_name
from all_tab_partitions
where table_name = upper('&Table_Name');
t_count number:=0;
begin
for i in c1
loop
execute immediate 'select count(1) from '||i.table_name||' partition('||i.partition_name||')' into t_count;
dbms_output.put_line('The Partition '||i.partition_name||' of table '||i.table_name||' has '||t_count||' rows');
end loop;
end;
/
___________________________________________________________________

No comments:

Post a Comment