Approach 1: DESCRIBE keyspaces;
Approach 2: SELECT * FROM system_schema.keyspaces;
cqlsh> DESCRIBE KEYSPACES; system_schema system_auth system system_distributed system_traces cqlsh> 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'} (5 rows)
As you see the output, you can see 5 pre-existing keyspaces. These commands list user defined keyspaces also.
cqlsh> CREATE KEYSPACE cassandratutorial WITH REPLICATION = ... { ... 'class' : 'SimpleStrategy', ... 'replication_factor' : 1 ... }; cqlsh> cqlsh> DESCRIBE KEYSPACES; system_schema system system_distributed system_auth cassandratutorial system_traces cqlsh> 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'} cassandratutorial | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1'} system_traces | True | {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'} (6 rows)
Note
Since
Cassandra support short form of the commands, you can even use ‘DESC’ instead of
‘DESCRIBE’.
cqlsh> DESC KEYSPACES; system_schema system system_distributed system_auth cassandratutorial system_traces
No comments:
Post a Comment