Difficulty: Beginner
Estimated Time: 5 minutes

Cassandra Query Language (CQL) looks like SQL because you can put data in tables containing rows and columns. So if you come from a SQL background, these terms (tables, rows and columns) have the same definition that they have in SQL. Isn't that helpful?

In this scenario, you will learn the essential CQL commands to effectively write and read data to Apache Cassandra, using the included cqlsh tool.

Congratulations! You've just completed the first step on the path to becoming a Cassandra whiz!

Help us make this better! Please give this scenario a ranking (click on the stars above).


Try It Out: Cassandra Query Language (CQL):

Step 1 of 7

Create a keyspace

Let's first start learning CQL by creating a keyspace, using the CREATE KEYSPACE command.

CREATE KEYSPACE demo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};

A keyspace is a way to logically group a collection of database objects together, such as:

  • tables
  • user-defined types
  • user-defined functions
  • and more!

This is similar concept to the database or namespace used in relational databases.

In addition, the keyspace also controls the replication behavior for all of the data stored in the keyspace.

ProTip: You can use the Tab key in cqlsh to auto-complete or suggest the next part of your command, as you type.

Great, you now know how to create a keyspace in Apache Cassandra!