欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle表空间中空表统计方法示例介绍

程序员文章站 2022-07-20 14:28:42
复制代码 代码如下: declare v_table tabs.table_name%type; v_sql varchar2(888); v_q number; curs...
复制代码 代码如下:

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;