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: Generate update / Insert scripts

Re: Generate update / Insert scripts

From: Howard J. Rogers <dba_at_hjrdba.com>
Date: Sat, 16 Mar 2002 16:50:55 +1100
Message-ID: <a6umgs$jvd$1@lust.ihug.co.nz>


As ever, no mention of Oracle version.

In 9i, there is the 'merge' SQL command, which will do precisely what you want... insert into T2 when there's a record in T1 which can't be found already in T2, but update T2 if there is such a matching record. Sometimes known as an 'upsert' because of the combination of update and insert activity in the one command.

Anything earlier than 9i... you're looking at writing some PL/SQL.

Regards
HJR

--
----------------------------------------------
Resources for Oracle: http://www.hjrdba.com
===============================


"Sunil" <sunil_franklin_at_hotmail.com> wrote in message
news:ftAk8.7$ht6.87_at_inet-nntp1.oracle.com...

> Hi Experts,
>
> I have two tables ( T1 and T2 ) having the same structure and data.
> Now T1 has some rows inserted into it and some of the column values in
> it are also updated.
> [Both T1 and T2 have an id (number) as the PK ]
>
> Is it possible for me to generate Insert / Update scripts, which will
> make the data in T2 the same as in T1.
>
>
> Thanks In advance,
> Sunil.
>
>
>
Received on Fri Mar 15 2002 - 23:50:55 CST

Original text of this message

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