Script to get row count of all tables in Oracle

Get row count of all tables in Oracle

Script:

set serverout on size 1000000
set verify off
declare
sql_stmt varchar2(1024);
row_count number;
v_table_name varchar2(40);
cursor get_tab is
select table_name
from dba_tables
where owner=upper('&&TABLE_OWNER');
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
v_table_name := get_tab_rec.table_name;
sql_stmt := 'select count(*) from &&TABLE_OWNER..'||get_tab_rec.table_name;
dbms_output.put_line(sql_stmt);
EXECUTE IMMEDIATE sql_stmt INTO row_count;
dbms_output.put_line('Table '||rpad(get_tab_rec.table_name,50)||' '||TO_CHAR(row_count)||' rows.');
END loop;
EXCEPTION 
when others then
dbms_output.put_line('Error counting rows for table '||v_table_name);
end;
/