可以用select count(*) from tab where tabtype='TABLE' and tname='表名';来查询表是否存在tab是一个系统视图
帮我调试: DECLARE i int;BEGIN SELECT count(*) INTO i from dba_tables where table_name='TEST'; IF (i>0) EXECUTE IMMEDIATE 'DROP TABLE TEST'; ELSE DBMS_OUTPUT.PUT_LINE('NOT EXISTS'); END IF; END;
可以用异常, begin execute immediate 'drop table xxxx'; exception when others then null; end;
DECLARE i int;BEGIN
SELECT count(*) INTO i from dba_tables where table_name='TEST';
IF (i>0)
EXECUTE IMMEDIATE 'DROP TABLE TEST';
ELSE
DBMS_OUTPUT.PUT_LINE('NOT EXISTS');
END IF;
END;
begin
execute immediate 'drop table xxxx';
exception
when others then
null;
end;