How to update clustering key in cassandra using update query?

前端 未结 2 1582
情歌与酒
情歌与酒 2021-01-18 21:33

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

Update styles set sequence=1 where styleid = \'CLASSIC\';
2条回答
  •  有刺的猬
    2021-01-18 22:16

    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.

    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.

提交回复
热议问题