INSERT

❗️

This is a legacy Apache Ignite documentation

The new documentation is hosted here: https://ignite.apache.org/docs/latest/

Inserts data into a table.

INSERT INTO tableName 
  {[( columnName [,...])]
  {VALUES {({DEFAULT | expression} [,...])} [,...] | [DIRECT] [SORTED] select}} 
  | {SET {columnName = {DEFAULT | expression}} [,...]}

Parameters

  • tableName - name of the table to be updated.
  • columnName - name of a column to be initialized with a value from the VALUES clause.

Description

INSERT command adds an entry or entries into a table (aka. cache in Ignite).

Since Ignite stores all the data in a form of key-value pairs, all the INSERT statements are finally transformed into a set of key-value operations.

If a single key-value pair is being added into a cache then, eventually, an INSERT statement will be converted into a cache.putIfAbsent(...) operation. In other cases, when multiple key-value pairs are inserted, the DML engine creates an EntryProcessor for each pair and uses cache.invokeAll(...) to propagate the data into a cache.

Refer to concurrent modifications section that explains how SQL engine solves concurrency issues.

Examples

Insert a new Person into the table:

INSERT INTO Person (id, name, city_id) VALUES (1, 'John Doe', 3);

Fill in Person table with the data retrieved from Account table:

INSERT 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 INSERT queries using native APIs:

See Also