SQL> select decode(count(0),0,'不存在','存在') T from user_tables where table_name = 'A';T
------
存在Executed in 0.016 secondsSQL> select decode(count(0),0,'不存在','存在') T from user_tables where table_name = 'AA';T
------
不存在Executed in 0.016 secondsSQL>

解决方案 »

  1.   

    试试这样:if exists(select 1 from user_tables where table_name = 'TABLE1') then
    drop table 'TABLE1';
    end if;不过与你的写法是一个意思来的,我怀疑是不是你运行存储过程的用户与TABLE1的用户不是同一个
      

  2.   

    if exists(select 1 from tab where tname = upper('TABLE1')) then
    drop  'TABLE1';
    end if;
      

  3.   

    假设p_table是表名变量,定义一个字符串变量v_strsql
    if exists(select 1 from tab where tname = upper(p_table)) then
      v_strsql:='drop table' || p_table   --拼sql
      execute immediate v_strsql;
    end if;
      

  4.   

    利用oracle中数据字典中的ALL_CATALOG视图可以查询到库中All tables, views, synonyms, sequences accessible to the user的信息现在我们利用它来查询SYSTEM用户下是否存在表'T_SYS_USER'
    select * from ALL_CATALOG t 
    where t.owner='SYSTEM'  
    and  t.table_type='TABLE'
    and t.table_name='T_SYS_USER'
    注意:'SYSTEM'  、'TABLE'、'T_SYS_USER'都必须是大写
    通过ALL_CATALOG视图可以很准确的判断一个表是否存在
      

  5.   

    v_count number;
    select count(*) into v_count from tab where tname=upper('table_name');
    if v_count = 1 then
        ......
    end if;