如何在cassandra中进行订购

时间:2015-06-09 07:33:34

标签: cassandra cql cql3

我在Cassandra中有一个表,其中包含一个字段ID。我已将该字段设置为partition key。现在我想通过id查询该表顺序。 如何使用Cql按ID的顺序从该表中选择所有行?

1 个答案:

答案 0 :(得分:2)

在Cassandra中,您无法通过分区键进行排序。 您只能在分区键

内订购

cql出错:

code=2200 [Invalid query] message="Order by is currently only supported on the clustered 
columns of the PRIMARY KEY, got id"

您必须创建一个 id 的表作为群集密钥,然后按 id 排序。