select * from tab
where tname='table temp'
判断是否有值

解决方案 »

  1.   

    fuxia(mike) :
    原理谁都懂,写出具体的语句好吗? feng1959(血踪万里) 
    我要的是删除掉一个table的语句,
    能给个能执行的吗?
      

  2.   

    写一个简单的存储过程
    create or replace procedure test1 is
       ls_tab_name varchar2(20);
    bdgin
       select tname into ls_tab_name from tab where tname='TEST'
       if ls_tab_name is not null then
          drop table test;
       end if;
    end test1;
      

  3.   

    写存储过程吧:
    DECLARE
        v_name user_tables.table_name%type;
    begin
        select table_name into v_name from user_tables where table_name = 'test';
        if v_name is not null then
            execute immediate 'drop table t1';
        end if;
    exception
     WHEN NO_DATA_FOUND then
      dbms_output.put_line('不存在此表');
    end;
      

  4.   

    declare v_count integer;
    begin
    Select Count(*) into v_Count from user_Tables where Table_Name='temp'
    if v_count >0 then
      drop table temp;
    end if;
    end;
      

  5.   

    不过很奇怪楼主为什么这么执著于表存不存在呢?
    存在你也是要删,不存在删了也没有问题,Oracle还会特别提示你。
      

  6.   

    lynx(lynx)如果表不存在,系统只是报一个msg,而不是报error导致程序终止的话就没问题
    我是怕有的数据库突然报错就导致程序终止,
    比如mysql,如果不加if exists的话在有的版本上就会有问题,
    当然,mssql是可以忽略错误的。oracle,db2,sybase里面可能又有所不一样,
    所以为了安全,最好还是先判断一下
    因为建表过程非常复杂,所以希望比较简洁
      

  7.   

    delphi里面用个try...except把错误屏蔽就行了
    try
      //exec drop table sql
    except
    end;