0

I have a Cassandra table:

CREATE TABLE test (
    c1 text primary key,
    c2 text
);

Column c2 has values like 'a', 'b', 'c', ... Now I want to change the value of c2 to 'a' for all rows. (Let's say I have ten thousand rows) What's the best way to do this in Cassandra?

In SQL, I can simply do

UPDATE test SET c2 = 'b';

But Cassandra doesn't allow it.

user2122264
  • 163
  • 1
  • 2
  • 7

2 Answers2

0

There's no CQL to do this in Cassandra. You could do it by retrieving all your c1 keys:

SELECT c1 from test;

then write a script that loops through and does

UPDATE test SET c2 = 'b' WHERE c1 = <c1>;

for each c1 returned.

Richard
  • 11,050
  • 2
  • 46
  • 33
-1

Cassandra is not an SQL database. I suggest to read the overview of low-level Cassandra API and architecture. It will give the good idea about what Cassandra can do, what it cannot do, what it is good at and what it is not good at. This example of mass-update requires independent updates of this specific column in each row in your table (column family) and each of these updates is a separate write operation.