· 9 years ago · Jan 13, 2017, 04:44 PM
1cqlsh:foo> CREATE TABLE test (
2 ... id int,
3 ... k text,
4 ... version int static,
5 ... v text,
6 ... PRIMARY KEY (id, k)
7 ... );
8cqlsh:foo> INSERT INTO test(id, version) VALUES (0, 0) IF NOT EXISTS
9 ... ;
10
11 [applied]
12-----------
13 True
14
15
16cqlsh:foo> select * from test;
17
18 id | k | version | v
19----+------+---------+------
20 0 | null | 0 | null
21
22(1 rows)
23cqlsh:foo> UPDATE test SET v='foo', version=1 WHERE id=0 AND k='k1' IF version = 0
24 ... ;
25
26 [applied]
27-----------
28 True
29
30cqlsh:foo> select * from test;
31
32 id | k | version | v
33----+----+---------+-----
34 0 | k1 | 1 | foo
35
36(1 rows)