如何获取Cassandra中所有记录的主键? [英] How can I get the primary keys of all records in Cassandra?

查看:78
本文介绍了如何获取Cassandra中所有记录的主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将大量数据插入Cassandra。现在,我想随机查询一条记录。
但是我不知道主键。因此,我想要一种方法来获取Cassandra中所有数据的主键,然后可以使用一个随机主键查询数据。

I have inserted plenty of data into Cassandra. Now I'd like to randomly query one record. But I don't know the primary key. So I want a way to fetch the primary keys of all data in Cassandra,then I can use one random primary key to query the data.

我可以从Cassandra的 data 目录中获得它吗?我只在该目录中找到.db文件。

Can I get it from the data directory of Cassandra? I only found .db files in that directory.

推荐答案

要获取主键值,可以在CQL中使用distinct:

To get the primary key values you can use distinct in CQL:

cqlsh> select distinct pkey_column FROM table;

或多个:

cqlsh> select distinct pkey_column_1, pkey_column_2 FROM table;

这篇关于如何获取Cassandra中所有记录的主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆