如何使用更新查询更新cassandra中的群集密钥? [英] How to update clustering key in cassandra using update query?

查看:434
本文介绍了如何使用更新查询更新cassandra中的群集密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的表结构,我使用以下查询更新序列:

This is my table structure and I am updating the sequence with the following query:

Update styles set sequence=1 where styleid = 'CLASSIC';

我收到错误消息为

PRIMARY KEY part sequence found in SET part
Missing PRIMARY KEY part sequence

CREATE TABLE styles (
  styleid ascii,
  sequence int,
  active boolean,
  image ascii,
  name ascii,
  PRIMARY KEY (styleid, sequence)
) WITH CLUSTERING ORDER BY (sequence DESC);

请任何人帮助我更新群集密钥序列,以便更新。或者任何替代方法请分享。

Please anyone help me to update the clustering key sequence so that it will be updated. Or any alternative method please share.

推荐答案

是的,直接更新聚类列是不可能的Cassandra,是做你需要做的事的方法。

While yes, updating the clustering columns directly is not possible in Cassandra, like everything, there are ways to do what you need to do.

您需要创建一个临时表,以表示数据的方式。然后,您将需要删除旧表,然后基于临时表创建一个新表。

You will need to create a temporary table that represents the data the way you want it to be. Then you will need to drop the old table, and then create a new table based on the temporary table.

我建议:
1)备份您的初始表,因为机会是第一次尝试这个时候你会错过什么。
2)编写一个程序以进行所需的更改(无论是Javascript程序,Java还是其他)。
3)测试,测试,然后再次测试(首先在本地进行测试,然后移动到集成样式环境,最后在某种预生产环境中测试,这是最接近您的生产环境。

I would suggest: 1) Backing up your initial table, because chances are the first time you try this you'll miss something. 2) Writing a program to make the changes you need (either a Javascript program, Java, whatever you are comfortable with). 3) Test, test, and then test again (first test locally, then move up to an integration style environment, and finally test on some sort of pre-prod environment, which is as close as you can get to your production environment.

这篇关于如何使用更新查询更新cassandra中的群集密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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