在cqlsh 2中是否有明确的“show keyspaces”?

时间:2013-05-17 15:11:46

标签: cassandra cql cqlsh

我可以使用什么cqlsh命令快速查看群集中的键空间? cqlsh不提供show keyspaces,而describe cluster并不像我想要的那样简洁。


我正在使用以下规范:

  

cqlsh 2.2.0,Cassandra 1.1.10,CQL spec 2.0.0,Thrift protocol 19.33.0

4 个答案:

答案 0 :(得分:100)

很简单。只需在cqlsh shell中输入此命令即可享受

 select * from system.schema_keyspaces;

在C * 3.x中,我们可以简单地使用

 describe keyspaces

答案 1 :(得分:46)

试试这个:

describe keyspaces


但是您可能需要大约以下内容的规范(而不是those mentioned自己Crowie

  

[cqlsh 4.1.1 | Cassandra 2.0.6 | CQL规范3.1.1 |节俭协议19.39.0]

答案 2 :(得分:10)

cqlsh> select * from system_schema.keyspaces;

 keyspace_name      | durable_writes | replication
--------------------+----------------+-------------------------------------------------------------------------------------
        system_auth |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'}
      system_schema |           True |                             {'class': 'org.apache.cassandra.locator.LocalStrategy'}
 system_distributed |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '3'}
             system |           True |                             {'class': 'org.apache.cassandra.locator.LocalStrategy'}
      system_traces |           True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'}

答案 3 :(得分:4)

C * 3.x系列的正确方法是:

List<KeyspaceMetadata> keyspaces = Cluster.getMetadata().getKeyspaces()

然后在KeyspaceMetadata实例上使用getName()