Apache Ignite SQL Documentation

The Apache Ignite SQL Developer Hub

Welcome to the Apache Ignite SQL developer hub. You'll find comprehensive guides and documentation to help you start working with Apache Ignite SQL as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

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 from VALUES 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 less than a minute ago

MERGE


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.