DBA Hub

📋Steps in this guide1/1

Get row_count of partitions of a table

set serverout on size 1000000 set verify off declare sql_stmt varchar2(1024); row_count number; cursor get_tab is select table_name,partition_name from dba_tab_partitions where table_owner=upper('&&TABLE_OWNER') and table_name='&&TABLE_NAME'; begin dbms_output.put_line('Checking Record Counts for table_name'); dbms_output.put_line('Log file to numrows_part_&&TABLE_OWNER.lst ....'); dbms_output.put

oracle configurationintermediate
by OracleDba
12 views
1

Get row_count of partitions of a table

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set serverout on size 1000000
set verify off
declare
sql_stmt varchar2(1024);
row_count number;
cursor get_tab is
select table_name,partition_name
from dba_tab_partitions
where table_owner=upper('&&TABLE_OWNER') and table_name='&&TABLE_NAME';
begin
dbms_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 loop
BEGIN
sql_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 then
dbms_output.put_line
('Error counting rows for table '||get_tab_rec.table_name);
END;
end loop;
end;
/
set verify on

Comments (0)

Please to add comments

No comments yet. Be the first to comment!