Inserts are always upserts

Suppose you try to insert data into a table with a primary key, which already exists; the data doesn't get updated in place. Rather, a new copy of the data is written, and the old copy is kept until it is deleted by some internal Cassandra mechanism. To demonstrate how this works, let's update one of the records using the INSERT statement.

Let's change Alice's email by running the following INSERT statement:

    INSERT INTO "users"     ("username", "email")     VALUES ('alice', 'alice@yahoo.com');

Let's query for the updated row and see what we get:

    SELECT * FROM "users" where "username"   = 'alice';

You can see that the ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.