Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set a value to null in cassandra with cql

How can I set a value of a row to null in cassandra? For example I have a table like this:

CREATE TABLE instruments (
                                              code text,
                                              ric text,
                                              primary key (code)
                                            )

if I want an element to have a particular ric:

update instruments set ric='test' where code='code';

But what about setting ric to None?

like image 740
nam Avatar asked Jul 22 '13 16:07

nam


2 Answers

It might be done with DELETE CQL command:

DELETE ric FROM instruments WHERE code='code';
like image 91
Wildfire Avatar answered Sep 23 '22 17:09

Wildfire


You can also use the value null in your queries. This was added last year to CQL.

update keyspace.table set ric=null where code='code';

You can also use null in insert statements, but if you omit the value it's the same as saying null so there's no point.

like image 24
2rs2ts Avatar answered Sep 23 '22 17:09

2rs2ts