Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Test for the exsistance of a table
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