nam
nam

Reputation: 3632

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?

Upvotes: 7

Views: 12517

Answers (2)

2rs2ts
2rs2ts

Reputation: 11026

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.

Upvotes: 5

Wildfire
Wildfire

Reputation: 6418

It might be done with DELETE CQL command:

DELETE ric FROM instruments WHERE code='code';

Upvotes: 13

Related Questions