-
Now, I’ll walk you thru some basic CRUD operations with Apache Cassandra 2.0.3 Command Line Interface (CLI).
Connect Cassandra Server:
connect localhost/9160;
Displaying existing Keyspaces:
show keyspaces;
Creating new keyspace:
create keyspace testkeyspace with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'
and strategy_options = {replication_factor:1};
Use existing keyspace:
use testkeyspace ;
Creating column family:
create column family users with comparator = UTF8Type and key_validation_class=UTF8Type and column_metadata = [{column_name: userName, validation_class:UTF8Type}, {column_name: email, validation_class:UTF8Type}];
Insert records into Columnfamily:
- set users['student01']['userName']='Student1';
- set users['student01']['email']='Student1@example.com';
Read existing record in a Columnfamily:
get users['student01']['userName'];
get users['student01'];
Update records in Columnfamily:
set users['student01']['email']='Student1@example.co.in';
Deleting records in Columnfamily:
- del users['student01']['email'];
del users['student01'];
Hope this helps someone.
No comments:
Post a Comment