CQL notes

Submitted by code_admin on Mon, 07/30/2018 - 13:27

Cassnadra

Common cql

  1. SELECT * FROM system_schema.keyspaces;
  2. describe keyspace XX
  3. describe tables
  4. SELECT * FROM xx

http://abiasforaction.net/a-practical-introduction-to-cassandra-query-l…

One Keyspace per application

Consistancy Level: QUORUM https://docs.datastax.com/en/cassandra/3.0/cassandra/dml/dmlConfigConsi…
Replication Factor: 3

cqlsh

tables->
primary key = (partition/row key + cluseter key)
- cluster key determines the order the data is stored

CREATE KEYSPACE animalkeyspace
WITH REPLICATION = { 'class' : 'SimpleStrategy' ,
'replication_factor' : 1 };

use animalkeyspace;

CREATE TABLE Monkey (
identifier uuid,
species text,
nickname text,
population int,
PRIMARY KEY ((identifier), species));

INSERT INTO monkey (identifier, species, nickname, population)
VALUES ( 5132b130-ae79-11e4-ab27-0800200c9a66,
'Capuchin monkey', 'cute', 100000);

$ApacheCassandraInstallDir/bin
and execute
nodetool flush animalkeyspace

find datafile:
cat $CASSANDRA_CONFIG/cassandra.yaml | grep -A 3 data_file_directories

Select * from monkey;

sstabledump /var/lib/cassandra/data/animalkeyspace/monkey-d672fb60463911e89a136dfe83fbca42/mc-1-big-Data.db

Tags

RJM Article Type
Quick Reference