Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 concise as I want.


I'm working using the following specifications:

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

like image 318
Crowie Avatar asked May 17 '13 15:05

Crowie


People also ask

How do I see all keyspaces in Cassandra?

Go to data tab > there you will see all keyspcaces created by you and some system keyspaces. You can see all tables under individual keyspaces and also replicator factor for keyspace.

How do you save keyspaces in Cassandra?

You can store the output in a file, then import with 'cassandra-cli -f filename'. If using cqlsh, you can use the 'describe schema' command. You can restrict to a keyspace with 'describe keyspace keyspace'. You can save this to a file then import with 'cqlsh -f filename'.

What are Cassandra keyspaces?

In a Cassandra cluster, a keyspace is an outermost object that determines how data replicates on nodes. Keyspaces consist of core objects called column families (which are like tables in RDBMS), rows indexed by keys, data types, data center awareness, replication factor, and keyspace strategy.

How can I get out of Cqlsh?

EXIT − Using this command, you can terminate cqlsh. PAGING − Enables or disables query paging. SHOW − Displays the details of current cqlsh session such as Cassandra version, host, or data type assumptions. SOURCE − Executes a file that contains CQL statements.


3 Answers

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 
like image 104
abhi Avatar answered Sep 23 '22 21:09

abhi


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]

like image 39
Peter Kipping Avatar answered Sep 24 '22 21:09

Peter Kipping


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'}
like image 26
Gabriel Wu Avatar answered Sep 23 '22 21:09

Gabriel Wu