Oracle: how to UPSERT (update or insert into a table?)

Posted by Mark Harrison on Stack Overflow See other posts from Stack Overflow or by Mark Harrison
Published on 2008-10-26T01:24:06Z Indexed on 2010/04/22 16:03 UTC
Read the original article Hit count: 166

Filed under:
|
|
|

The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row that matches the data:

if table t has a row exists that has key X:
    update t set mystuff... where mykey=X
else
    insert into t mystuff...

Since Oracle doesn't have a specific UPSERT statement, what's the best way to do this?

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about sql