Join us for Scylla University LIVE, 28th of July
Learn More >

Lab 2: Basic CQL Operations

8 min to complete

Lab 2: Basic CQL Operations

As noted in Lab 1, In addition to the instructions provided here, which allow you to run the lab on a machine with Docker, you can find this lab in the Katacoda learning environment here. The Katacoda environment provides an interactive virtual machine where you can execute all the commands directly from your browser without the need to configure anything.

After seeing how to run a single Scylla instance in the last lab, and running the CQL Shell, in this lab, we will see how to run some basic CQL commands. We will work with our newly created Scylla instance to create a table, insert data into it, and read the data.


Let’s start by making sure our node is  still up:

docker exec -it scyllaU nodetool status

Run a CQL shell:

docker exec -it scyllaU cqlsh 

Create a keyspace called “mykeyspace”:

CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1};

Keep in mind that SimpleStrategy should not be used in production.

Next, create a table with three columns: user id, first name, and last name, and insert some data:

use mykeyspace; 
CREATE TABLE users ( user_id int, fname text, lname text, PRIMARY KEY((user_id))); 

Insert into the newly created table two rows:

insert into users(user_id, fname, lname) values (1, 'rick', 'sanchez'); 
insert into users(user_id, fname, lname) values (4, 'rust', 'cohle'); 

Read the table contents:

select * from users;

To summarize, we saw how easy it is to start a Scylla cluster and perform some basic CQL operations. In the next lessons, we will see some more advanced commands.

Read more about the CQL shell here.