liveBook · Manning

Upsert

As explained in ScyllaDB in Action

An upsert is a write operation that combines insert and update behavior by creating missing data or modifying existing data.

An upsert combines insert and update behavior. In ScyllaDB, an UPDATE writes values without first checking whether the row exists: existing rows change, while missing rows are created. section 2.3.3

Use an upsert by following the row’s primary-key path:

  • Start with UPDATE and name the table. section 2.3.3
  • Set the columns whose values should be written. section 2.3.3
  • Filter with the partition key and other identifying columns in WHERE. section 2.3.3
  • Leave unchanged columns untouched when updating an existing row. section 2.3.3

Updating a restaurant review

An UPDATE can revise the fried-chicken review for Ernie’s Eats. Reading the row afterward shows the new review while its other columns remain unchanged. An equivalent INSERT writes the same complete row.

This differs from SQL’s usual UPDATE expectation: SQL generally implies that the row already exists, whereas ScyllaDB avoids a preliminary existence check to keep writes fast. section 2.3.3

How ScyllaDB in Action covers it

How deep it goes
Explains syntax, partition-key filtering, preserved columns, and deferred deeper treatment of row liveness.
Examples
Uses an Ernie’s Eats fried-chicken review, UPDATE and INSERT statements, and a SELECT result.
What you can do after
Apply upserts with CQL UPDATE statements while preserving unchanged columns and targeting the partition key.
How it connects
Connects UPDATE with INSERT, SELECT, DELETE, SQL, partition keys, and row liveness.

Also explained in

Compare how 3 books explain upsert →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.