Database Reference
In-Depth Information
use twitter;
create table users(user_id text primary
key,followers set<text>, tweet_date
timestamp, tweet_body text, first_name text);
2.
Let's insert a record for row key ' imvivek ' using the if not ex-
ists command
insert into
users(user_id,tweet_date,tweet_body,first_name)
values('imvivek','2013-12-31','good bye
2013','vivek') if not exists;
3.
Let's re-run the same command with first_name as
'vivek_update'
insert into
users(user_id,tweet_date,tweet_body,first_name)
values('imvivek','2013-12-31','good bye
2013','vivek_update') if not exists;
In Figure 3-15 , since before executing the command at step 2 the
table was empty and no records existed; hence, it gets successfully
applied, but the same fails at step 3.
Figure 3-15 . A CAS operation to insert a row with id imvivek if it doesn't exist
4.
Let's try to use CAS to update users for adding followers for a user
having the first name “vivek”
update users set followers = {'apress'} where
user_id='imvivek' if first_name='vivek'
 
 
Search WWH ::




Custom Search