Cassandra 2 - 使用CQL 3列出现有索引 [英] Cassandra 2 - list existing indexes with CQL 3
本文介绍了Cassandra 2 - 使用CQL 3列出现有索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有CQL查询来列出特定键空间或列族的所有现有索引?
Is there a CQL query to list all existing indexes for particular key space, or column family?
推荐答案
使用系统键空间的主键和辅助索引:
You can retrieve primary keys and secondary indexes using the system keyspace:
SELECT column_name, index_name, index_options, index_type, component_index
FROM system.schema_columns
WHERE keyspace_name='samplekp'AND columnfamily_name='sampletable';
以下面的表格声明为例:
Taking, for example, the following table declaration:
CREATE TABLE sampletable (
key text,
date timestamp,
value1 text,
value2 text,
PRIMARY KEY(key, date));
CREATE INDEX ix_sample_value2 ON sampletable (value2);
上面的查询会得到这样的结果:
The query mentioned above would get something this results:
column_name | index_name | index_options | index_type | component_index
-------------+------------------+---------------+------------+-----------------
date | null | null | null | 0
key | null | null | null | null
value1 | null | null | null | 1
value2 | ix_sample_value2 | {} | COMPOSITES | 1
这篇关于Cassandra 2 - 使用CQL 3列出现有索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文