Database Reference
In-Depth Information
Updating multiple rows
As it turns out,
bob
and
carol
both live in
St. Louis, MO
. We could update each of
their records individually, but the
UPDATE
statement also supports the same
WHERE…IN
construct that we used previously in the
SELECT
statements. So, we can update both of
their records in a single query:
UPDATE "users"
SET "location" = 'St. Louis, MO'
WHERE "username" IN ('bob', 'carol');
Now, on checking the
users
table again, we'll see that the change was applied to both
rows:
Note
While the preceding
UPDATE
statement allows us to update rows in a single statement,
these updates are not isolated: it is possible that, while the update is in progress, another
client may see a value in one of the rows but not the other. Writes to Cassandra are always
isolated within a single partition but there is no way to guarantee isolation across partitions.