O'Reilly logo

Apache Cassandra Essentials by Nitin Padalia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create keyspace and column family

Now, let's create our keyspace and a column family using the cqlsh client. Run the command cqlsh, then you should be on the cqlsh prompt. On the cqlsh prompt, run the keyspace creation command as follows:

cqlsh> CREATE KEYSPACE cassandrademodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

Here, we created a keyspace named cassandrademodb. We chose the replication factor as 3, so each data row we'll be creating will be stored on three nodes. Since, for now we're running our cluster on only one cluster, we chose the replication strategy as SimpleStrategy.

Now, create one column family called users in this keyspace. Here, we'll use username column as the partition key. Using the cqlsh ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required