Hi,

Here is a question on how we should define the meaning of an UPSERT
statement. UPSERT is not part of the ISO/ANSI SQL standard, so we have some
leeway to define it.

My personal feeling is that UPSERT should either insert a brand-new row or
it should completely replace an existing row, but it should never combine
columns from a new and an existing row. If users want the latter then they
should use the MERGE command.

We should probably follow what other DBMSs do. I could not yet find a DBMS
that had an UPSERT command, although there probably is one.


   - PostgreSQL: Has an insert with a conflict clause, similar to our
   MERGE: http://www.postgresql.org/docs/current/static/sql-insert.html


   - MySQL: Has an insert with ON DUPLICATE KEY clause, similar to our
   MERGE: http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html


   - Teradata: Has an update ... else insert ... command, similar to MERGE:
   https://forums.teradata.com/forum/enterprise/problem-using-upsert


   - Oracle just seems to have the MERGE statement and various methods to
   do upsert in PL/SQL:
   
http://stackoverflow.com/questions/237327/oracle-how-to-upsert-update-or-insert-into-a-table

This seems to support indirectly what I'm proposing. If we want to merge
old and new row then we should use syntax specifying how to merge, which is
what the other DBMSs have done.

See also the discussion in
https://github.com/apache/incubator-trafodion/pull/380. I wanted to see
whether the user group has any input on this.

Thanks,

Hans

Reply via email to