Help › Write SQL

Query Cassandra

Write CQL on Cassandra and ScyllaDB connections: statements and batches, cqlsh's CONSISTENCY and TRACING, completion that knows the partition key, and which statements ask first.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

On a Cassandra connection, the editor takes CQL, the Cassandra Query Language, the way cqlsh and Cassandra's documentation write it:

SELECT device, ts, reading
  FROM readings
  WHERE device = 7f3e2a10-4c1b-4d2e-9a8f-0b6c5d4e3f21 AND day = '2026-10-08'
  LIMIT 50;

CQL looks like SQL but is a language of its own: there are no joins, a WHERE names a table's partition key, and writes replace what is there. Querlyn reads it as CQL, never as SQL. Running, cancelling, the results and the history work as for SQL; see Run statements and scripts.

Write statements

  • Statements end at ;. A batch, BEGIN BATCH … APPLY BATCH, is one statement: the ;s inside it do not end it, and it runs as one request.
  • cqlsh's own commands end at the end of their line, with or without ;, so a CONSISTENCY QUORUM line does not swallow the query below it.
  • Values are CQL's: strings in '…', blobs as 0xCAFE, UUIDs and time UUIDs written bare, durations as 1h30m, collections as […], {…} and {key: value}, and function bodies between $$ and $$.
  • Names are folded to lower case unless written in double quotes, as "OrderLines".
  • Comments are -- or // to the end of the line, and /* … */. ⌘/ on macOS or Ctrl+/ on Windows and Linux comments lines with --.

cqlsh's commands

WriteWhat it does
CONSISTENCYSays the tab's consistency level.
CONSISTENCY QUORUMSets it for this tab, as Consistency in the toolbar does.
SERIAL CONSISTENCY LOCAL_SERIALSets the level of conditional writes' Paxos round.
TRACING ON, TRACING OFFTraces each statement that follows: its trace is shown as a second result, step by step with the node and the microseconds.
USE shopA CQL statement: moves the tab to the keyspace.
DESCRIBE …A CQL statement on Cassandra 4.0 and later.

COPY, SOURCE, CAPTURE, LOGIN, SHOW, PAGING and EXPAND are not run: COPY and CAPTURE say to use Export results, and the results grid reads pages as you scroll.

Completion

Completion offers what fits where the cursor is: statements at the start, tables after FROM, INTO, UPDATE and TRUNCATE (views only where a table is read), the tables of a keyspace after keyspace., keyspaces after USE, and functions and the table's columns in the select list. In a WHERE the partition key's columns come first, then the clustering columns in order; other columns say they need an index or ALLOW FILTERING. SET offers only columns that are not part of the key, and ORDER BY only clustering columns. Types follow a column's name in CREATE TABLE, and consistency levels follow CONSISTENCY. See Complete SQL as you type.

ALLOW FILTERING is underlined with a warning: it reads every partition the WHERE does not narrow down, across the cluster. On a Production connection Querlyn also asks before it runs such a statement (see Safety).

Safety

Querlyn judges each statement before it runs, and each statement of a batch.

  • On Testing, Staging and Production, it asks first for statements that destroy data: DROP KEYSPACE, DROP TABLE, DROP MATERIALIZED VIEW and the other DROPs, TRUNCATE, ALTER TABLE … DROP, and a DELETE that does not name one whole primary key, because it removes a whole partition or a range of rows. A DELETE of one row, or of a row's columns, does not ask. REVOKE asks too: it takes permissions or roles away.
  • A GRANT is not checked for what it gives away: Production asks about it.
  • Whether a DELETE names a whole key is judged by the table's key in the sidebar's metadata. When Querlyn has not read that table's key yet, the DELETE is treated as one it cannot judge.
  • A statement Querlyn cannot read is treated as one that changes data: Production asks, a read-only connection refuses it.
  • On Production, a SELECT with ALLOW FILTERING asks first. It changes nothing, but it reads every partition the WHERE does not narrow down, on every node. Other connections run it with the editor's warning only.
  • On Production, Explain asks first. Cassandra has no plans to estimate, so Explain runs the SELECT with tracing and reads its first page of rows.
  • A read-only connection refuses every write and schema change.
  • Writes replace what is there. An INSERT of an existing key overwrites the row, and an UPDATE of a missing one creates it; add IF NOT EXISTS or IF EXISTS to make them conditional.

See Confirm risky statements and Read-only connections.

Help for Querlyn 0.1.0. All help topics