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: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 23 Aug 2002 14:41:33 -0700
Message-ID: <92eeeff0.0208231341.56b8f2e9@posting.google.com>


dennis.grisbeck_at_software-innovation.no (DG) wrote in message news:<d6bd69c1.0208230228.b35b53_at_posting.google.com>...
> 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!

If you are doing this from a script, then why do you care if table exists or not. If you want to drop a table, just type SQL> drop table foo;. If Oracle does not find the table... it will complain nicely without any harm. However, if you are doing this from a PL/SQL block then look up Dynamic PL/SQL.

I have seen this few times in this NG. Is dropping a table in MSSQL such a big deal that you *absolutely* have to find out if it exists or not?

//Rauf Sarwar Received on Fri Aug 23 2002 - 16:41:33 CDT

Original text of this message

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