Alter cassandra column family primary key using cassandra-cli or CQL
Asked Answered
W

1

11

I am using Cassandra 1.2.5. After creating a column family in Cassandra using cassandra-cli, is it possible to modify the primary key on the column family using either cassandra-cli or CQL?

Specifically, I currently have the following table (from CQL):

CREATE TABLE "table1" (
  key blob,
  column1 blob,
  value blob,
  PRIMARY KEY (key, column1)
);

I would like the table to be as follows, without having to drop and recreate the table:

CREATE TABLE "table1" (
  key blob,
  column1 blob,
  value blob,
  PRIMARY KEY (key)
);

Is this possible through either cassandra-cli or CQL?

Werner answered 24/8, 2013 at 18:16 Comment(0)
M
16

The primary keys directly determine how and where cassandra stores the data contained in a table (column family). The primary key consists of partition key and clustering key (optional).

The partition key determines which node stores the data. It is responsible for data distribution across the nodes. The additional columns determine per-partition clustering (see compound key documentation).

So changing the primary key will always require all data to be migrated. I do not think that either cqlsh or cassandra-cli have a command for this (as of 2015)..

Monecious answered 26/8, 2013 at 9:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.