[Go-essp-tech] Idempotent SQL?

Gavin M. Bell gavin at llnl.gov
Fri Feb 4 11:27:44 MST 2011


 Hi Feiyi,

Thanks... but that's not quite it. :-(  Bob suggested this as well but
that is not the same thing as idempotent at least not w.r.t. the
scenario I have in mind.... If I have a table that is already there and
is populated with stuff, I don't want to drop the table, I just want the
create not to happen.  Same thing for schema creation.  Especially in
the latter case, I don't want to drop me schema if it applies to a
larger set of tables than then sql script in question is written to
address.  Basically you should be able to run this script over and over
and over, and each time after the first, it doesn't bomb telling you
things already exist.

I can't be the only person in the world that wants this... H2 figured
this out, is there anything that I can do to get functionality I am
looking for from postgres?  Grrrr... postgres... su#@$%&

Help!?

On 2/4/11 10:11 AM, Wang, Feiyi wrote:
> For postgres, I think you can do:
>
> if table exists, drop the table first
> otherwise create.
>
> Feiyi
>
>
> On Feb 4, 2011, at 12:53 PM, Gavin M. Bell wrote:
>
> Hi,
>
> :-(
> I tried that... it doesn't work for postgres :-|.
> I am trying to find the analogous command for postgres.
>
> (maybe we should just use H2...) ;-).
>
>
> On 2/4/11 9:50 AM, Cinquini, Luca (3880) wrote:
> Hi Gavin,
> this kind of statements worked for Java H2DB - not sure about postgres...
>
> -- WORKFLOW INSTANCE TYPE
> CREATE TABLE IF NOT EXISTS WORKFLOW_INSTANCE_TYPE (
> TYPE INT PRIMARY KEY NOT NULL,
> DESCRIPTION VARCHAR(200) NOT NULL
> );
> MERGE INTO WORKFLOW_INSTANCE_TYPE (TYPE, DESCRIPTION ) VALUES (1, 'DESDynI Standard');
>
> Luca
>
> On Feb 4, 2011, at 10:45 AM, Gavin M. Bell wrote:
>
> Hey SQL Mavens...
>
> Does anyone know how to create idempotent SQL scripts?
> If something is there already, then don't create it...
> If it is not, then do so.
> (the pithier the better)
>
> Thanks
>
> --
> Gavin M. Bell
> Lawrence Livermore National Labs
> --
>
>  "Never mistake a clear view for a short distance."
>                -Paul Saffo
>
> (GPG Key - http://rainbow.llnl.gov/dist/keys/gavin.asc)
>
>  A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E
>
>
> _______________________________________________
> GO-ESSP-TECH mailing list
> GO-ESSP-TECH at ucar.edu<mailto:GO-ESSP-TECH at ucar.edu>
> http://mailman.ucar.edu/mailman/listinfo/go-essp-tech
>
>
>
> --
> Gavin M. Bell
> Lawrence Livermore National Labs
> --
>
>  "Never mistake a clear view for a short distance."
>                -Paul Saffo
>
> (GPG Key - http://rainbow.llnl.gov/dist/keys/gavin.asc)
>
>  A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E
>
>
> _______________________________________________
> GO-ESSP-TECH mailing list
> GO-ESSP-TECH at ucar.edu<mailto:GO-ESSP-TECH at ucar.edu>
> http://mailman.ucar.edu/mailman/listinfo/go-essp-tech
>

-- 
Gavin M. Bell
Lawrence Livermore National Labs
--

 "Never mistake a clear view for a short distance."
       	       -Paul Saffo

(GPG Key - http://rainbow.llnl.gov/dist/keys/gavin.asc)

 A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/go-essp-tech/attachments/20110204/94ef2386/attachment.html 


More information about the GO-ESSP-TECH mailing list