get row counts of tables in schema without using dba_tables.num_rows [message #470404] |
Mon, 09 August 2010 15:08 |
jxh461
Messages: 185 Registered: March 2005
|
Senior Member |
|
|
Hi,
I am trying to get a row count(*) for all the tables in my schema. The NUM_ROWS column in DBA_TABLES is not appropriate in this case because they are as good as the last analyze. So I need to get real time counts.
I tried the following code but I can't seem to catch my error.
DECLARE
l_sql varchar2(150);
cursor tablelist is
select table_name from dba_tables where owner = 'ME';
tabs tablelist%rowtype;
n_rowcnt number;
Begin
open tablelist;
loop
fetch tablelist into tabs;
exit when tablelist%notfound;
l_sql := 'select count(*) ROW_COUNT from '||tabs||' ;';
n_rowcnt := l_sql;
dbms_output.put_line(tabs,n_rowcnt);
end loop;
close tablelist;
end;
I am getting the following error:
ORA-06550: line 18, column 20:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 18, column 11:
PL/SQL: Statement ignored
ORA-06550: line 21, column 11:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 21, column 11:
PL/SQL: Statement ignored
My expected results are :
TABLE_NAME ROW_COUNT
---------- ----------
Please help or advise if there is a better way.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|