【问题标题】:cassandra query with additional where clause and filter带有附加 where 子句和过滤器的 cassandra 查询
【发布时间】:2019-11-13 03:21:51
【问题描述】:

我正在尝试从 cassandra 中的表中删除,我想根据不属于主键的附加 where 子句进行删除,但我也可以传递主键。场景是我想从搜索表中删除一条记录,该记录在附加列中具有目标表 ID。搜索字段是主键 例如:

目标表:

create table user (id text primary key, email text, other_data text)

搜索表:

create table emails(email text primary key, id text)

现在我想从电子邮件表中删除,只有当电子邮件属于特定 ID 时。如果我发出如下声明可以吗: delete from emails where email ='a@test.com' and id ='abc'

这需要允许过滤,否则会报错。

【问题讨论】:

    标签: cassandra


    【解决方案1】:

    您尝试执行的语法不起作用(在 WHERE 条件中有不属于主键的备用列)。

    您可以执行以下操作:

    delete from emails where email ='a@test.com' if id = 'abc';
    

    这会起作用,但这里有一个注意事项:

    Conditional deletions incur a non-negligible performance cost and should be used sparingly.
    

    不确定您的陈述的数量,但可能会注意到大量数量。

    -吉姆

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-06
      • 2020-08-18
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      相关资源
      最近更新 更多