【问题标题】:set a value to null in cassandra with cql使用 cql 在 cassandra 中将值设置为 null
【发布时间】:2013-07-22 16:01:36
【问题描述】:

如何在 cassandra 中将一行的值设置为 null? 例如我有一个这样的表:

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

如果我想让一个元素有一个特定的ric

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

但是如何将ric 设置为None

【问题讨论】:

    标签: nosql cassandra cql


    【解决方案1】:

    可以用DELETE CQL command:

    DELETE ric FROM instruments WHERE code='code';
    

    【讨论】:

      【解决方案2】:

      您还可以在查询中使用值null。这是 CQL 的 added last year

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

      您也可以在insert 语句中使用null,但如果省略该值,则与null 相同,因此没有意义。

      【讨论】:

        猜你喜欢
        • 2016-03-25
        • 2017-02-23
        • 2012-03-08
        • 1970-01-01
        • 2014-11-15
        • 1970-01-01
        • 2018-05-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多