为什么我的Cassandra更新无法正常工作? [英] Why doesn't my Cassandra update work?

查看:117
本文介绍了为什么我的Cassandra更新无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Cassandra表:

I have the following Cassandra table:

创建表start_stop(id文本,开始文本,结束文本,价格double,PRIMARY KEY( id,start));

我这样插入:

插入start_stop(id,start)值('123','w');

现在我想要进行更新:

update start_stop set end ='z'其中id ='123';

,我得到一个错误:
InvalidRequest:code = 2200 [Invalid query] message =缺少某些聚类键:start

除了进行查询以在更新之前查找起始值外,如何解决此问题?

How can I fix this, aside from doing a query to look up the start value before doing an update?

推荐答案

您的主键不完整,并且cassandra仅在存在主键匹配的情况下才能更新行。

Your primary key is incomplete, and cassandra can only update rows if there is a primary key match.

如果您查看表结构,则(id,start)组合在一起会构成主键,其中id是分区键。

If you look at your table structure, (id, start) combined makes primary key, out of which id is partition key.

在cassandra中有更新和插入之间没有区别,但是在两种情况下,您都需要具有完整的主键,cassandra才能找到特定的行。

In cassandra there is no difference between update and insert, but in either case, you need to have complete primary key, for cassandra to find specific row.

您需要使用以下任意一种

You need to use either of below to update.

update start_stop set end = 'z' where id = '123' and start='w';

insert into start_stop (id, start, end) values ('123', 'w', 'z');

这篇关于为什么我的Cassandra更新无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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