declare
v_count number(10);
v_table_name varchar2(50);
str varchar2(300);
v_if number(9);
begin
select count(*) into v_count from all_tables;
--DBMS_OUTPUT.put_line(v_count);输出该用户可访问的表数量
for i in 1..v_count loop
str:='select table_name into v_table_name from (select all_tables.table_name,rownum rn from all_tables) where rn='||i;
--DBMS_OUTPUT.put_line(STR);
execute immediate str;
str:='select count(*) into v_if from '||v_table_name;
execute immediate str;
if v_if>1 then
dbms_output.put_line(v_table_name);
end if;
end loop;
end;
------解决思路----------------------
如果你对所有的表都进行了表分析,可以通过如下语句得到:
SELECT table_name FROM all_tables t WHERE t.NUM_ROWS > 1
常规的做法是:
先用如下SQL得到所有表数据技术的查询语句:
SELECT 'select '''
------解决思路----------------------
table_name
------解决思路----------------------
''' as table_name, count(1) as row_num from '
------解决思路----------------------
owner
------解决思路----------------------
'.'
------解决思路----------------------
table_name
------解决思路----------------------
' union all'
FROM all_tables
然后在上述的结果上嵌一层:select * from () where row_num > 1
就能得到你想要的结果了
------解决思路----------------------
可以像楼上说的那样对表进行分析
或者查表也行,但是不应该这么写,效率太差了
declare
v_count number(10);
v_table_name varchar2(50);
str varchar2(300);
v_if number(9);
begin
select count(*) into v_count from all_tables where table_name not like 'BIN$%';
--DBMS_OUTPUT.put_line(v_count);输出该用户可访问的表数量,回收站中的表除外
for x in (select owner,table_name from all_tables where table_name not like 'BIN$%')loop
execute immediate 'select count(1) into v_if from "'
------解决思路----------------------
x.owner
------解决思路----------------------
'"."'
------解决思路----------------------
x.table_name
------解决思路----------------------
'" where rownum<=2' into v_if;
if v_if >1 then
dbms_output.put_line(x.owner
------解决思路----------------------
'.'
------解决思路----------------------
x.table_name);
end if;
end;