日期:2014-05-16 浏览次数:20732 次
--给个例子 declare num number; begin select count(1) into num from all_tables where table_name='TESTA'; if num>0 then execute immediate 'drop table TESTA'; end if; execute immediate 'create table TESTA as select * from dept'; end; /
------解决方案--------------------
SET serveroutput ON; declare i integer; BEGIN i:=0; SELECT count(*) INTO i FROM user_tables WHERE table_name='TB'; IF i=1 THEN EXECUTE IMMEDIATE 'drop table tb'; dbms_output.put_line('删除成功'); ELSE dbms_output.put_line('删除失败'); END IF; end;