I want to change my cassandra table. I know that if i need to add extra primary key, i have to create another table. For example, I want to turn this table
create table sample1 (
p1 int,
p2 timestamp,
c1 text,
c2 text,
c3 text,
c4 text,
x1 int,
x2 int,
x3 int
PRIMARY KEY((p1,p2),c1,c2,c3,c4)
);
into this table
create table sample1 (
p1 int,
p2 timestamp,
c1 text,
c2 text,
c3 text,
c4 text,
c5 text,
c6 text,
x1 int,
x2 int,
x3 int
PRIMARY KEY((p1,p2),c1,c2,c3,c4,c5,c6)
);
This situation will be happened again, i will be have to change this table again.
I am considering to create table like this. Do you think that is it best approach? Or is there another way?
create table sample1 (
p1 int,
p2 timestamp,
combined_six_field text,
c1 text,
c2 text,
c3 text,
c4 text,
c5 text,
c6 text,
x1 int,
x2 int,
x3 int
PRIMARY KEY((p1,p2), combined_six_field)
);
select * from sample1 where p1=x and p2=y and c1 ='z'
– Ashraful Islam