From: joel garry <>
Date: Wed, 28 Jan 2009 11:09:10 -0800 (PST)
Message-ID: <>

On Jan 28, 7:18 am, "Wilfrid" <> wrote:
> Hello,
> There has been many communication on the exists command on newsgroups, web
> sites... but I could not find anything close to this (below) that it can be
> possible with MS SQL.
> I am migrating databases and scripts from SQL to Oracle and I am trying to
> make things as simple as possible.
> Is there a simple way with oracle that does the same thing as the script
> below in SQL?
> I am testing if the table 'tablename' exists in the schema and if no create
> it.
> IF OBJECT_ID('tablename') is null
> CREATE TABLE tablename
> (
> id int not null,
> name nvarchar(10) null
> )
> go
> Thanks in advance for your help

An additional warning, only because I've seen it often from people coming from MS: creating tables is something you don't normally want

to do at runtime.  It's an expensive operation, and DDL does commits
before and after.  If you need work tables, see the concept of global
temporary tables.  A fellow named Tom Kyte has written some excellent
books describing these and other implementation differences you need to know about when switching database engines.

As far as installation or migration scripts and such, it's a reasonable thing to do as Mark described, though I've never been a fan of blindly dropping tables.

SQL is a language, not something owned by Microsoft. EXISTS happens to be a language statement in SQL, so your thread heading is a bit misleading, as you found when you searched for it. Just so you know, it helps to have the heading reflect the thread.


-- is bogus.
Received on Wed Jan 28 2009 - 13:09:10 CST

Original text of this message