【问题标题】:Is there a clear equivalent of 'show keyspaces' in cqlsh 2?cqlsh 2 中是否有明确的“显示键空间”等价物?
【发布时间】:2023-04-06 18:22:01
【问题描述】:

我可以使用什么 cqlsh 命令来快速查看集群中的键空间? cqlsh 不提供show keyspacesdescribe cluster 没有我想要的简洁。


我正在使用以下规范:

cqlsh 2.2.0、Cassandra 1.1.10、CQL 规范 2.0.0、Thrift 协议 19.33.0

【问题讨论】:

    标签: cassandra cql cqlsh


    【解决方案1】:

    非常简单。只需在您的 cqlsh shell 中输入此命令即可享受

     select * from system.schema_keyspaces;
    

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

     describe keyspaces
    

    【讨论】:

    【解决方案2】:

    试试这个:

    describe keyspaces
    


    不过,您可能需要大约以下规格(而不是自己 those mentioned Crowie

    [cqlsh 4.1.1 |卡桑德拉 2.0.6 | CQL 规范 3.1.1 | Thrift 协议 19.39.0]

    【讨论】:

      【解决方案3】:
      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'}
      

      【讨论】:

      【解决方案4】:

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

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

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

      【讨论】:

      • 嘿Bsb。我认为这个答案仅与您想在 Java 中获取此信息时有关。那是对的吗?我的问题旨在集中在 cqlsh 控制台查询上。抱歉,如果我看起来有点不对劲……显然几年前就问过这个问题,现在我自己没有使用 C*。询问以便我可以通过编辑改进您的答案,或者可能支持并改进其他答案 m