declare
num number;
begin
select nvl(max(1),0) into num from user_tables where table_name=...; 
if num=0 then
..
else
存在;
end if;
end;
/

解决方案 »

  1.   

    谢谢,但是还有个问题
    nvl(max(1),0)是什么意思啊?
    我只明白如果表不存在则返回0,存在的话是1!
    不过请具体说明一下,谢谢!
      

  2.   

    nvl的作用是将空值转换为其他值,如上所示
    nvl(max(1),0)的作用就是当表不存在时,实际会返回一个空值,但我们将他人为的改为0
      

  3.   

    另外我认为beckhambobo(beckham)所说的语句:select nvl(max(1),0) into num from user_tables where table_name=...; 可改为select nvl(1,0) into num from user_tables where table_name=...; 但不知max在这里是否有别的用途?是否还会有特殊情况发生,还是什么?望指教
      

  4.   

    max()函数的作用是判断此查询语句是不是能返回数据,若能,则说明表名存在
    类似用exists关键字
      

  5.   

    尝试用NO_DATA_FOUND异常来做,触发这个异常就建表