Script to check the row count of partitions for a table
Script to check the row count of partitions for a table
count_tab.sql
set serverout on size 1000000set verify offdeclaresql_stmt varchar2(1024);row_count number;cursor get_tab isselect table_name,partition_namefrom dba_tab_partitionswhere table_owner=upper('&&TABLE_OWNER') and table_name='&&TABLE_NAME';begindbms_output.put_line('Checking Record Counts for table_name');dbms_output.put_line('Log file to numrows_part_&&TABLE_OWNER.lst ....');dbms_output.put_line('....');for get_tab_rec in get_tab loopBEGINsql_stmt := 'select count(*) from &&TABLE_OWNER..'||get_tab_rec.table_name||' partition ( '||get_tab_rec.partition_name||' )';
EXECUTE IMMEDIATE sql_stmt INTO row_count;dbms_output.put_line('Table '||rpad(get_tab_rec.table_name||'('||get_tab_rec.partition_name||')',50)||' '||TO_CHAR(row_count)||' rows.');exception when others thendbms_output.put_line('Error counting rows for table '||get_tab_rec.table_name);END;end loop;end;/set verify on
No comments:
Post a Comment