Lab: Basic CQL Operations (Part 2 of 2)

8 min to complete

Lab: Basic CQL Operations (Part 2 of 2)

After seeing how to run a single ScyllaDB 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 ScyllaDB 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' : 'NetworkTopologyStrategy', 'replication_factor' : 1};

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 ScyllaDB 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.

fa-angle-up