pl/sql里面?begin
execute immediate 'create table tbname ...';
exception when others then
           null;--表已经存在
end;

解决方案 »

  1.   

    好象没有这样的判断,你直接就把drop table 加上,也不影响结果,如果是不能删除表的情况下,我想只能用存储过程来实现了,动态执行!好象没有太好的办法!
      

  2.   

    SQL> declare
      2  strsql varchar2(100);
      3  count1 number(1);
      4  begin
      5  select count(*) into count1 from user_tables where table_name='TEST';
      6    if count1>0 then
      7  strsql:='Drop table TEST';
      8  execute immediate strsql;
      9  end if;
     10  end;
      

  3.   

    SQL> declare
      2  strsql varchar2(100);
      3  count1 number(1);
      4  begin
      5  select count(*) into count1 from user_tables where table_name='TEST';
      6  if count1=0 then
      7  strsql:='create table TEST(a varchar2(20))';
      8  execute immediate strsql;
      9  else
     10  dbms_output.put_line('表存在');
     11  end if;
     12  end;
     13  /PL/SQL 过程已成功完成。SQL> /
    表存在PL/SQL 过程已成功完成。SQL>