Is there a clear equivalent of 'show keyspaces' in cqlsh 2?

后端 未结 4 1140
礼貌的吻别
礼貌的吻别 2020-12-23 16:38

What cqlsh command can I use to quickly see the keyspaces in a cluster? cqlsh does not provide show keyspaces and describe cluster isn\'t as concis

相关标签:
4条回答
  • 2020-12-23 17:01

    Very simple. Just enter this command in your cqlsh shell and enjoy

     select * from system.schema_keyspaces;
    

    In C*3.x, we can simply use

     describe keyspaces
    
    0 讨论(0)
  • 2020-12-23 17:01

    Just try this:

    describe keyspaces
    


    However you may need specs of approximately the following (rather than those mentioned by yourself Crowie)

    [cqlsh 4.1.1 | Cassandra 2.0.6 | CQL spec 3.1.1 | Thrift protocol 19.39.0]

    0 讨论(0)
  • 2020-12-23 17:10

    The correct way with C* 3.x series is:

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

    Then use getName() on the KeyspaceMetadata instances.

    0 讨论(0)
  • 2020-12-23 17:11
    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'}
    
    0 讨论(0)
提交回复
热议问题