Enter a cqlsh session on a running dockerised Cassandra
docker exec - it cassandra_container_name_or_id cqlsh
Create table with PK(partition_key, clustering_column)
CREATE TABLE table_name (name text , age text , job text , PRIMARY KEY (name, age));
INSERT INTO table_name (name, age, job) VALUES (" Mark" , " 21" , " Developer" );
select * from table_name;
SELECT statement with WHERE and LIMIT
select * from table_name where field_name= ' field_value' limit 1 ;
SELECT statement with WHERE on non-PK field (allow filtering)
select * from table_name where non_pk_field_name= ' field_value' allow filtering;
SELECT with "OR" alternative (in)
select * from keyspace .table_name WHERE field_name in (' something' ,' something_else' );
SELECT COUNT (* ) FROM keyspace .table_name ;
Return distinct partition keys
SELECT DISTINCT partition_key FROM keyspace .table_name ;
BEGIN BATCH
INSERT INTO keyspace .table_name (fieldA, fieldB) VALUES (' hello' , ' world' );
INSERT INTO keyspace .table_name (fieldA, fieldB) VALUES (' foo' , ' bar' );
APPLY BATCH;
BEGIN BATCH
UPDATE keyspace .table_name SET fieldA= ' bonjour' , fieldB= ' earth' WHERE fieldC= ' blah' AND fieldD= ' something' ;
UPDATE keyspace .table_name SET fieldA= ' ola' , fieldB= ' world' WHERE fieldC= ' halb' AND fieldD= ' something_else' ;
APPLY BATCH;
Make output of Cassandra commands a bit prettier