liveBook · Manning

CQL shell

As explained in ScyllaDB in Action

cqlsh is a command-line shell for connecting to Cassandra-compatible databases and executing Cassandra Query Language statements.

cqlsh is a command-line shell for connecting to a ScyllaDB cluster and running Cassandra Query Language (CQL) statements. ScyllaDB reuses Cassandra’s cqlsh because it speaks the same protocol. The prompt shows the connected node and component versions, then accepts CQL commands. section 2.2.2

$ docker exec -it scylla-1 cqlsh

Open the shell from the running ScyllaDB Docker container, then issue CQL statements at the cqlsh prompt. section 2.2.2

Use the shell to build a database from the outside in: create a keyspace, create tables inside it, and add data. CQL deliberately resembles simpler SQL forms, but data modeling differs because ScyllaDB has no JOINs; related data may instead be stored together through denormalization. section 2.2.2

Save restaurant reviews

A food-review table accepts INSERT statements in cqlsh. Each write names the target columns and values, including escaped single quotes in strings. Reviews from the same restaurant can remain distinct when their primary-key values, such as ordered time and food, differ. section 2.3.1 section 2.5

cqlsh supports common cluster data tasks:

  • Create keyspaces and tables with CREATE KEYSPACE and CREATE TABLE. section 2.2.2
  • Read and write data with familiar CQL operations such as SELECT and INSERT. section 2.5
  • Change or remove data with UPDATE upserts and DELETE statements. section 2.5

How ScyllaDB in Action covers it

How deep it goes
Demonstrates Docker access, schema creation, and INSERT writes, while deferring denormalization techniques to later treatment.
Examples
Uses Docker shell access and restaurant reviews for Ernie’s Eats and Really Good Ramen as runnable CQL artifacts.
What it assumes
Introduces shell commands and CQL schema work from zero; familiarity with SQL syntax can ease the transition.
What you can do after
Apply it via cqlsh to create keyspaces and tables and read, write, update, or delete cluster data.
How it connects
Connects CQL shell use to CQL, SQL, keyspaces, tables, primary keys, partition keys, replication, and denormalization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.