CQL, cqlsh, and Basic CQL Syntax

2 min to complete

CQL, cqlsh, and Basic CQL Syntax

As Scylla is a drop-in replacement for Apache Cassandra, it supports CQL.

CQL is a query language that is used to interface with Scylla. It allows us to perform basic functions such as insert, update, select, delete, create, and so on.

CQL is in some ways similar to SQL however there are some differences.

Here are some examples of commonly used CQL commands:

CREATE TABLE heartrate_v1 (
   pet_chip_id uuid,
   time timestamp,
   heart_rate int,
   PRIMARY KEY (pet_chip_id)
);
INSERT INTO heartrate_v1(pet_chip_id, time, heart_rate) VALUES (123e4567-e89b-12d3-a456-426655440b23, '2019-03-04 07:01:00', 100);
SELECT * from heartrate_v1 WHERE pet_chip_id = 123e4567-e89b-12d3-a456-426655440b23;
DELETE FROM heartrate_v1 WHERE pet_chip_id = 123e4567-e89b-12d3-a456-426655440b23;

You’ll have a chance to run these later on. For a full reference of CQL commands, see here.

cqlsh

The CQL Shell is an interactive Command Line Interface to interact with the database. The connection is established to any one of the nodes, which is then designated as the coordinator node for that specific connection. The coordinator node manages the request path and the response back to the client.

To enter the cqlsh mode we would type cqlsh:

$ cqlsh <node_ip>

We’ll see an example of that later on in this lesson, with a chance to try it hands on.

Quizzes
fa-angle-up