Path: news.easynews.com!easynews!newshub2.home.com!newshub2.rdc1.sfba.home.com!news.home.com!enews.sgi.com!newspeer2.tds.net!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
From: Ron Reidy <ron@indra.com>
Newsgroups: comp.databases.oracle.server
Subject: Re: How to conditionally copy and then create it using SQL scripts
Date: Wed, 10 Oct 2001 05:27:05 -0600
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <3BC43089.356EEE4B@indra.com>
X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686)
X-Accept-Language: en
MIME-Version: 1.0
References: <de83f985.0110100042.43dac84f@posting.google.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: newsabuse@supernews.com
Lines: 22
Xref: easynews comp.databases.oracle.server:120787
X-Received-Date: Wed, 10 Oct 2001 05:59:20 MST (news.easynews.com)

zl wrote:
> 
> 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,
>        .....
> )
> 
> How can I do this in Oracle? Oracle doens't allow "if" appears in
> sqlplus.
You have to use PL/SQL and dynamic SQL.  See the docs.
-- 
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
