将主键放在cassandra中以更新记录 [英] Put primary keys in cassandra for updating record

查看:76
本文介绍了将主键放在cassandra中以更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在卡桑德拉有一张桌子。
我的任务是:
我想选择具有时间范围的记录(因此时间戳必须是主键,并且不使用允许过滤)
当我插入记录并且表中存在provider_id和filename时,记录已更新

I have a table in cassandra. My task is: I want to select records with time range (so timestamp must be primary key, and not use allow filtering) when I insert record and provider_id and filename exists in table, the record is updated

CREATE TABLE test (
    name text,
    filename text,
    timestamp timestamp,
    is_deleted boolean,
    PRIMARY KEY (provider_id, filename, timestamp)
)


推荐答案

您无法更新主键列,它将插入另一条记录

这就是cassandra的工作方式。

您必须选择带有provider_id,文件名的时间戳,然后使用provider_id,文件名和时间戳进行删除,并使用新时间戳重新插入

You can't update primary key column, It will insert another record.
That's how cassandra work.
You have to select the timestamp with provider_id, filename then delete with provider_id, filename and timestamp and reinsert with new timestamp

这篇关于将主键放在cassandra中以更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆