问题描述
CREATE TABLE footable (
column1 text,
column2 text,
column3 text,
column4 text,
PRIMARY KEY ((column1, column2))
)
在上面的示例中,我从通过部分分区键查询Cassandra ,是否可以在第一个分区键并选择第二个分区键上的所有条件?
In the example above which I got from Querying Cassandra by a partial partition key, is it possible to use condition on the 1st partition key and select all condition on 2nd partition key?
示例cql语句可能如下所示:
Example cql statement may look like this:
select * from footable where column1 = 'name' and column2 ALL;
Cassandra中是否存在类似的查询?
Is there some sort of querying like this in Cassandra?
推荐答案
否。为了支持该查询,(在您的表定义中)您必须将PRIMARY KEY修改为仅使用 column1
作为分区键,并指定 column2
作为聚簇键:
No. To support that query, (in your table definition) you would have to modify the PRIMARY KEY to only use only column1
as the partition key, and designate column2
as a clustering key:
PRIMARY KEY ((column1), column2)
然后此查询将返回您想要的结果:
Then this query would return your desired results:
select * from footable where column1 = 'name';
这篇关于Cassandra部分分区键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!