CQL for Cassandra 2.x

Example of creating a keyspace

To query Cassandra, you first create and use a keyspace. You can chose an arbitrary data center name and register the name in the properties file of the snitch. Alternatively, if you use a cluster in a single data center, simply use the default data center name in OS Cassandra, for example datacenter1 and skip registering the name in the properties file.


  1. Create a keyspace.
    cqlsh> CREATE KEYSPACE demodb WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 };
  2. Use the keyspace.
    USE demodb;