Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Test for the exsistance of a table

Re: Test for the exsistance of a table

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Fri, 08 Mar 2002 22:14:21 +0000
Message-ID: <3C8937BD.4DC5@yahoo.com>


Philip Morrow wrote:
>
> Is there a way to test for the exsistance of a table with SQL code. I need
> to test to see if a table exsists and if so drop it. If it doesn't the drop
> table statement doesn't need to be executed.
>
> Thanks for the help.
>
> Phil

How about...

begin
  execute immediate 'drop table ...'
exception
  when others then
    if sqlcode = -942 (or whatever it is for object does not exist) then

        null;
    else

        raise;
    end if;
end;

Dropping tables on the fly in a production environment does suggest certain flaws in the design :-)

-- 
==============================
Connor McDonald

http://www.oracledba.co.uk

"Some days you're the pigeon, some days you're the statue..."
Received on Fri Mar 08 2002 - 16:14:21 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US