declare
countq number;
begin
select  count(table_name) into countQ from all_tables where table_name='TEST';
if(countQ>0) then
  execute immediate 'drop table test';
else
  execute immediate 'create table test...';
end if;
end;

解决方案 »

  1.   

    SQL> drop table tb1;表已丢弃。SQL> begin
      2   begin
      3   execute immediate 'drop table tb1';
      4   exception when others then
      5      null;
      6   end;
      7  execute immediate 'create table tb1(
      8             aa number,
      9             bb number)';
     10  end;
     11  /PL/SQL 过程已成功完成。SQL>
      

  2.   

    贊同  yxxx(小孬) 
      

  3.   

    取不出来countQ 
    select  count(table_name) into countQ from all_tables where table_name='TEST';
      

  4.   

    你还不如就直接CREATE呢.如果存在就直接报错也不执行,就得了北
      

  5.   

    什么意思啊?
    你要判断的表名替代代码中的'TEST'就行了
    要是表不存在,countq就为0;存在,countq就为1啊。
      

  6.   

    不用这么麻烦
    直接用exception 处理就行了。
      

  7.   

    先到数据字典(all_tables)里去找有否相应的表名,然后就可以做进一步处理。