Question

Is there any way to prevent the CQL command Update from creating a new row if the row key 'row1' doesn't exist?

UPDATE columnfamily SET data = 'test data' WHERE key = 'row1';
Was it helpful?

Solution

Update 2015-04-10:

As of Cassandra 2.0 you can use light weight transactions to accomplish this. Be aware that although they are called "light weight" these queries require a lot more work to be done on the Cassandra cluster.

Thanks to @BSB for the update.

Pre 2.0 answer:

No. Unlike in SQL, in CQL Update and insert are semantically the same. You would have to do a read first to determine the existence of the row.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top