On Github kalmanb / cassandra-basic-presentation
UPDATE member SET name = 'Kal'
UPDATE member SET time = NOW()
var now = CurrentTime()
try {
execute("UPDATE member SET time = ${now}")
} ...
SELECT * FROM member WHERE id = 123* Linear scale
SELECT * FROM member WHERE time > '2011-02-03' AND time <= '2012-01-01'* Very fast but need to be sharded
SELECT *
FROM member
WHERE id = 15
SELECT *
FROM member
WHERE id = 15
SELECT id
FROM member
WHERE city = 'Auckland'
SELECT id
FROM member
WHERE time > '2011-02-03'
AND time < '2012-01-01'
SELECT id
FROM member
WHERE city = 'Auckland'
AND time > '2011-02-03'
AND time < '2012-01-01'
SELECT id
FROM member
WHERE city = 'Auckland'
AND status = 'VIP'
AND time > '2011-02-03'
AND time < '2012-01-01'
SELECT id
FROM member
WHERE time > '2011-02-03'
AND time < '2012-01-01'
AND city = 'Auckland'
We can only have a single range query and it must be at the last field
UPDATE UserActions
SET total = total + 2
WHERE user = '9908-4AE3'
AND action = 'click';
DELETE phone
FROM Users
WHERE userid
IN ('AF08-40F3', '9908-4AE3');
CREATE TABLE monkeySpecies (
species text PRIMARY KEY,
common_name text,
population varint,
average_size int
) WITH comment='Important biological records'
AND read_repair_chance = 1.0;
CREATE TABLE timeline (
userid uuid,
posted_month int,
posted_time uuid,
body text,
posted_by text,
PRIMARY KEY (userid, posted_month, posted_time)
) WITH compaction = { 'class' : 'LeveledCompactionStrategy' };
BEGIN BATCH
INSERT INTO users (userid, password, name)
VALUES ('user2', 'ch@ngem3b', 'second user');
UPDATE users SET password = 'ps22dhds' WHERE userid = 'user3';
INSERT INTO users (userid, password) VALUES ('user4', 'ch@ngem3c');
DELETE name FROM users WHERE userid = 'user1';
APPLY BATCH;
If any of the batch succeeds then all of it will
CREATE TABLE member (
id text PRIMARY KEY,
favs map<text, text=""> // A map of text keys, and text values
)
// Inserting (or Updating)
INSERT INTO members (id, favs)
VALUES ('jsmith', { 'fruit' : 'apple', 'band' : 'Beatles' })</text,>
INSERT INTO member (name, city) VALUES (‘John’, ‘Auckland’) IF NOT EXISTS;
UPDATE member SET email = 'new@gmail.com' IF email = 'orig@gmail.com';