Hello,

H2's MERGE INTO statement is quite elegant. While it isn't as powerful
as the SQL standard or MySQL's ON DUPLICATE KEY UPDATE clause, it is a
lot simpler and intuitive than others. I was wondering if you had
previously thought about adding an additional, optional DELETE flag.
Something along these lines:

MERGE INTO target (id, t1, t2)
KEY (id)
WITH DELETE
SELECT id, s1, s2 FROM source

The syntax is just an example. Of course, this clause would work with
both SELECT and VALUES variants of the MERGE statement. Oracle
supports such a clause, and I find it quite useful. See the Oracle
documentation for details:
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm

With a single statement, I could:

- Select a source data set
- Insert all new records into a target table
- Update all existing records in the target table
- Delete all "obsolete" records from the target table

This differs from a simple TRUNCATE+INSERT in the fact that updates
are possible, e.g. large updates with few additions and few removals.
What do you think?

Cheers
Lukas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to