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

Home -> Community -> Usenet -> c.d.o.misc -> Re: IF Exists SQL statement help

Re: IF Exists SQL statement help

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Fri, 23 Aug 2002 16:38:36 GMT
Message-ID: <3D6664FB.E97F4929@exesolutions.com>


DG wrote:

> In Microsoft sequal server I have this statement:
>
> if exists (select * from dbo.sysobjects where id =
> object_id('[my_table]') and OBJECTPROPERTY(id,'IsUserTable') = 1) DROP
> TABLE [my_table]
> GO
>
> this obviously checks to see if a table exists before executing the
> drop table statement.
>
> what would the Oracle equivalent of this be?
>
> Thanks from an Oracle newbie!

An inefficient TSQL thing that has no place in the Oracle world. In Oracle:

BEGIN
   EXECUTE IMMEDIATE 'DROP TABLE xyz';
EXCEPTION
   WHEN OTHERS THEN

As Sybrand says ... study Oracle. If you try to do TSQL in Oracle you will create insecure, corrupt, poorly performing, unscalable, junk that someone else will get paid to rewrite.

Daniel Morgan Received on Fri Aug 23 2002 - 11:38:36 CDT

Original text of this message

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