Updates can create new rows

The INSERT statements aren't the only write operations in CQL that can have unexpected effects. To see how UPDATE can take us by surprise, let's update the gina row to add a location:

UPDATE "users" SET "location" = 'Houston, TX' WHERE "username" = 'gina'; 

Wait a second—who's gina? So far, we haven't had a user with the username gina in our table. We might expect the preceding UPDATE statement to have no effect; after all, our WHERE statement specifies a row that does not exist.

The contents of the users table, however, tell a different story:

There is now a row with the primary key gina. It turns out that an ...

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.