Database Reference
In-Depth Information
WHERE primary_key_name { = pk_value | IN ( pk_value1,
pk_value2, ... ) }
IF column_name = col_val [ AND column_name = column_value
... ];
Most of the things in the previous expression follow the same rule as we have seen in the
previous sections under Inserting data , Collections in CQL , and Lightweight transactions .
So, you can update to set TTL or TIMESTAMP of an individual or a set of columns. In
simple cases like regular columns or collection columns with full replacement, you just go
ahead and provide the value. But in cases like adding or removing collections, we use the
+ or - operator and sometime the DELETE query as we have seen in the Collections in
CQL section previously.
Here are a couple of examples:
# Create a table and insert some data
CREATE TABLE update_demo ( id int PRIMARY KEY, name text,
movies list <text> );
INSERT INTO update_demo (id, name, movies) VALUES ( 1,
'imdb', ['Beautiful Mind', 'Se7en', '1984'] );
INSERT INTO update_demo (id, name, movies) VALUES ( 10,
'rotten tomato', ['Star Wars', 'Donnie darko'] );
# Update a couple of rows
UPDATE update_demo SET name = 'Movie Website' WHERE id in
(1,10);
SELECT * FROM update_demo;
id | movies | name
----+-------------------------------------+---------------
10 | ['Star Wars', 'Donnie darko'] | Movie Website
1 | ['Beautiful Mind', 'Se7en', '1984'] | Movie Website
Search WWH ::




Custom Search