oracle数据库中找出空表 无 declare v_table tabs.table_name%type; v_sql varchar2(888); v_q number; cursor c1 is select table_name tn from tabs; type c is ref cursor; c2 c; begin dbms_output.put_line('以下为空数据表的表名:'); for r1 in c1 loop
oracle数据库中找出空表 declare v_table tabs.table_name%type; v_sql varchar2(888); v_q number; cursor c1 is select table_name tn from tabs; type c is ref cursor; c2 c; begin dbms_output.put_line('以下为空数据表的表名:'); for r1 in c1 loop v_table :=r1.tn; v_sql :='select count(*) q from '||v_table; open c2 for v_sql; loop fetch c2 into v_q; exit when c2%notfound; if v_q=0 then dbms_output.put_line(v_table); end if; end loop; close c2; end loop; exception when others then dbms_output.put_line('error occurred'); end;
select * from dba_segments where blocks <= 1 and segment_type = 'table';