MERGE
This is a legacy Apache Ignite documentation
The new documentation is hosted here: https://ignite.apache.org/docs/latest/
Merge data into a table.
MERGE INTO tableName [(columnName [,...])]
[KEY (columnName [,...])]
{VALUES {({ DEFAULT | expression } [,...])} [,...] | select}
Parameters
tableName
- the name of the table to be updated.columnName
- the name of a column to be initialized with a value fromVALUES
clause.
Description
MERGE
command updates existing entries and insert new entries that don't exist.
Since Ignite stores all the data in a form of key-value pairs, all the MERGE
statements are finally transformed into a set of key-value operations.
MERGE
is one of the most straightforward operations because it is translated into cache.put(...)
and cache.putAll(...)
operations depending on the number of rows that need to be inserted or updated as part of the MERGE
query.
Refer to concurrent modifications section that explains how SQL engine solves concurrency issues.
Examples
Merge a couple of rows into Person
table:
MERGE INTO Person(id, name, city_id) VALUES
(1, 'John Smith', 5),
(2, 'Mary Jones', 5);
Fill in Person
table with the data retrieved from Account
table:
MERGE INTO Person(id, name, city_id)
(SELECT a.id + 1000, concat(a.firstName, a.secondName), a.city_id
FROM Account a WHERE a.id > 100 AND a.id < 1000);
Note
Java, .NET, C++ users can execute MERGE
queries using native APIs:
See Also
Updated over 4 years ago