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    

Update data in a table.

UPDATE tableName [[AS] newTableAlias]
  SET {{columnName = {DEFAULT | expression}} [,...]} |
  {(columnName [,...]) = (select)}
  [WHERE expression][LIMIT expression]

Parameters

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

Description

UPDATE command alters existing entries stored in a table.

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

Initially, SQL engine generates and executes a SELECT query based on the UPDATE WHERE clause and only after that it modifies the existing values that satisfy the clause result.

The modification is performed via cache.invokeAll(...) operation. Basically, it means that once the result of the SELECT query is ready, SQL engine will prepare a number of EntryProcessors and will execute all of them using cache.invokeAll(...) operation. While the data is being modified using EntryProcessors, additional checks are performed to make sure that nobody has interfered between the SELECT and the actual update.

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

❗️

Primary Keys Updates

Ignite does not allow updating a primary key because the latter defines a partition the key and its value belong to statically. While the partition with all its data can change several cluster owners, the key always belongs to a single partition all the times. The partition is calculated using a hash function applied to the key's value.

Considering this, if a key needs to be updated it has to be removed and inserted consequently.

Examples

Update column name of an entry:

UPDATE Person SET name = 'John Black' WHERE id = 2;

Update Person table with the data taken from Account table:

UPDATE Person p SET name = (SELECT a.first_name FROM Account a WHERE a.id = p.id)

Note

Java, .NET, C++ users can execute UPDATE queries using native APIs:

See Also

Updated less than a minute ago

UPDATE


Suggested Edits are limited on API Reference Pages

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