问题
I want to store snapshots of an object in Apache Cassandra 1.2
Row key is the Object#ID and there will be a column for each snapshot.
-------- latest -------- v2 -------- v1
id-122 100 -------- 50 -------- 66
--------
So column names are created dynamically at runtime.
How to create the previous table in Cassandra 1.2 using CQL3?
回答1:
You would use the compound primary key feature of CQL3:
CREATE TABLE foo (
object_id int,
version int,
value int,
PRIMARY KEY (object_id, version));
回答2:
In CQL3, Table schema is fixed. So you can't really get dynamic column names. For that you have to switch to CQL2.
来源:https://stackoverflow.com/questions/14720472/create-a-table-in-cassandra-1-2-with-cql3-where-column-names-will-be-created-at