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: How to conditionally copy and then create it using SQL scripts

Re: How to conditionally copy and then create it using SQL scripts

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 10 Oct 2001 11:27:59 -0700
Message-ID: <9q23vf0209f@drn.newsguy.com>


In article <de83f985.0110100042.43dac84f_at_posting.google.com>, lzhang_at_bj.bexcom.com says...
>
>In SQL server, the following SQL statements can be used to create a
>table if it is not existed.
>
>
>IF EXISTS (SELECT * FROM sysobjects
> WHERE name = 'BusinessDocIdGenerator'
> AND type = 'U')
> DROP TABLE BusinessDocIdGenerator
>
>CREATE TABLE BusinessDocIdGenerator (
> NumericGeneratorId int NULL,
> .....
>)

begin

   for x in ( select * from user_tables where table_name = 'FOO' ) loop

       execute immediate 'drop table foo';    end loop;
end;
/
create table foo ( x int );

>
>
>How can I do this in Oracle? Oracle doens't allow "if" appears in
>sqlplus.

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Wed Oct 10 2001 - 13:27:59 CDT

Original text of this message

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