Database Reference
In-Depth Information
select * from users;
Figure 3-16 shows the result of retrieving records after the CAS
update operation.
Figure 3-16 . Rows after succesfully updating using the CAS operation
Secondary Index over Composite Columns
With Cassandra 2.x onward, Cassandra allows the secondary index over clustering
keys, which allows the user to run queries using EQ operater. Prior to 2.x, it was pos-
sible to include the remaining cluster key in a where clause only if the preceding clus-
tering key part was available in the where clause.
Let's use the same Twitter example discussed within the “Composite Columns”
section.
1.
First, let's create a keyspace twitter and column family users :
create keyspace twitter with replication =
{'class':'SimpleStrategy','replication_factor':1};
use twitter;
create table users(user_id text,followers
set<text>, tweet_date timestamp, tweet_body
text, first_name text, PRIMARY
KEY(user_id,tweet_date, first_name));
2.
Let's Store a few colums in the users column family for user_id
'imvivek' :
// insert records for 'imvivek'
insert into
users(user_id,tweet_date,tweet_body,first_name)
 
 
Search WWH ::




Custom Search