Book Image

Learning Apache Cassandra

By : Matthew Brown
4 (1)
Book Image

Learning Apache Cassandra

4 (1)
By: Matthew Brown

Overview of this book

Table of Contents (19 chapters)
Learning Apache Cassandra
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 it worked by reading from the users table again:

SELECT * FROM "users";

As we hoped, alice now has a location:

Note

A full reference for the UPDATE statement can be found in the DataStax CQL documentation at http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/update_r.html

Updating multiple columns

As in the SQL UPDATE statement, we can specify multiple column-value pairs to be updated in a...