Database Reference
In-Depth Information
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 exist-
ing 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 documenta-