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: Any way to "conditionally" drop a table?

Re: Any way to "conditionally" drop a table?

From: Sybrand Bakker <gooiditweg_at_sybrandb.nospam.demon.nl>
Date: Tue, 28 Oct 2003 00:10:29 +0100
Message-ID: <0a9rpvoc2et6sv6qinb72tkhcu0ot9fd16@4ax.com>


On 27 Oct 2003 14:39:54 -0800, david.karr_at_wamu.net (David M. Karr) wrote:

>This is probably a FAQ, but I haven't been able to find any good
>information about this. Perhaps that means the answer is that I can't
>do it, but I'll give it a try anyway.
>
>In writing db setup scripts, it's convenient to add a "drop table"
>statement before "create table" statements. This works fine if the
>table already existed. If the table didn't exist, the script fails.

Not true. With the standard sql*plus error handling, the script will continue.

>
>Is it practical/feasible to write Oracle-specific SQL that I can pass
>through JDBC that will only drop the table if it exists, and ignore it
>if it doesn't exist? I remember a colleague at another job doing this
>quite a while ago, but I can't remember how it was done.

I don't think anyone should even consider to run DDL through jdbc. This is utterly unsafe. You also don't want to allow an arbitrary end-user be capable to run installation like scripts. You'll end up in a mess, if you are not in one already.

Use sql*plus for installation scripts, as this is an one-time operation anyway, and don't even consider using jdbc.

--
Sybrand Bakker, Senior Oracle DBA
Received on Mon Oct 27 2003 - 17:10:29 CST

Original text of this message

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