...
select count(*) into v_exist from tab where table_name='YOU_TABLE';
if v_exist>0 then
  execute immediate  'drop table your_table';
...

解决方案 »

  1.   

    我在过程中是这样做的,
      str := 'declare ';
      str := str||' num number;';
      str := str||' begin ';
      str := str||' select count(*) into num from tabs where tablespace_name = ''ZFJC'' and table_name = ''temp_1112'';'; 
      str := str||' if num>0 then';
      str := str||' drop table temp_1112;';
      str := str||' end if;';
      str := str||' end;';
      dbms_output.put_line(str);    
      execute immediate str;  
      commit;
    但它执行时给我这样的错误提示:
    ORA-06550: 第 1 行, 第 139 列: 
    PLS-00103: 出现符号 "DROP"在需要下列之一时:
    begindeclareexitforgotoif
       loopmodnullpragmaraisereturnselectupdatewhile<an identifier>
       <a double-quoted delimited-identifier><a bind variable><<
       closecurrentdeletefetchlockinsertopenrollbacksavepointsetsql
       executecommitforall<a single-quoted SQL string>
    ORA-06512: 在"ZFJC.TEST123", line 47
    ORA-06512: 在line 1
      

  2.   

    我写的本来就是过程啊
    就是drop一个表,用的着你那么一堆吗?
      

  3.   

    可是如果按你那样写,它编译不通过呀!
    select count(*) into num from tabs where table_name = 'temp_1112';
      if num>0 then
      execute immediate 'drop table temp_1112';
      end if ;
      commit;