Updating the existing rows

Now that we've got a new location column, we can add some data to it. Any new user records we create, of course, can have a location value, but perhaps some of our existing users would like to input their location value too. To do this, we need to be able to update existing rows. The process should, once again, look quite familiar to anyone who is familiar with SQL:

UPDATE "users" SET "location" = 'New York, NY' WHERE "username" = 'alice';

Like the INSERT and DELETE statements, the UPDATE statement does not give us any feedback on the operation. However, we can confirm whether it worked by reading from the users table again:

SELECT * FROM "users"; 

As we hoped, alice now has a location:

A full reference for ...

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.