Skip to content

Instantly share code, notes, and snippets.

@tzach
Last active December 27, 2020 15:39
Show Gist options
  • Save tzach/8885eaaa9d512e02a301b3a731ec2f66 to your computer and use it in GitHub Desktop.
Save tzach/8885eaaa9d512e02a301b3a731ec2f66 to your computer and use it in GitHub Desktop.
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
USE mykeyspace;
CREATE TABLE guards (firstname text, lastname text, state boolean, room_temp int, PRIMARY KEY ((firstname, lastname)));
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('tzach', 'livyatan', false, 25);
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('tzach', 'livyatan', false, 24);
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('guy', 'Guy Shtub', false, 25);
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('laura', 'novich', false, 23);
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('avishai', 'Ish Shalom', true, 24);
INSERT INTO guards (firstname, lastname, state, room_temp) VALUES ('ivan', 'Prisyazhnyy', true, 25);
UPDATE guards SET state = false WHERE firstname = 'tzach' AND lastname = 'livyatan';
select * from guards ;
UPDATE guards SET state = true WHERE firstname = 'tzach' AND lastname = 'livyatan';
select * from guards ;
UPDATE guards SET state = true WHERE firstname = 'tzach' AND lastname = 'livyatan' IF room_temp > 30;
select * from guards ;
UPDATE guards SET room_temp = 31 WHERE firstname = 'tzach' AND lastname = 'livyatan';
UPDATE guards SET state = true WHERE firstname = 'tzach' AND lastname = 'livyatan' IF room_temp > 30;
select * from guards ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment