首先你使用1、select t.table_name,t.num_rows from user_tables t;查询不到结果时,可以手动执行分析user_tables表,过程如下:1)
create or replace function count_rows(table_name in varchar2,owner in varchar2 default null)
return number authid current_user IS
num_rows number;
stmt varchar2(2000);
begin
if owner is null then
stmt := 'select count(*) from "' || table_name || '"';
else
stmt := 'select count(*) from "' || owner || '"."' || table_name || '"';
end if;
execute immediate stmt
into num_rows;
return num_rows;
end;
2)、
分析表:
analyze table tablename compute statistics;
之后,再执行select t.table_name,t.num_rows from user_tables t;
要先对表T做统计分析
Oracle不是实时的对表进行分析的,需要手动执行分析,参考楼上的语句