Tuesday, 12 January 2016

Cassandra tutorial


                           Installation and Commands of Cassandra

Download cassandra from-


Extract package set path in bashrc file.
Java is prerequested for cassandra.

Start cassandra,

/user/local/cassandra> ./cassandra

Start cassandra shell using,

/user/local/cassandra>./cqlsh

And you can create keyspace in cassandra,

CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;

Check keyspaces,
cqlsh> desc keyspaces;

Use keyspaces,
cqlsh> use mykespace;
Show tables,
cqlsh> desc tables;


Statements-

CREATE
cqlsh:mykeyspace> CREATE TABLE mykeyspace.users (
user_id int PRIMARY KEY,
fname text,
lname text
) ;

INSERT
cqlsh:mykeyspace> insert into users(user_id,fname,lname) values(1748,'Priyanka','Pal');
SELECT
cqlsh:mykeyspace> SELECT * FROM users;

UPDATE
cqlsh:mykeyspace> Update users set fname='Priyanka' where user_id=1748;

DELETE
cqlsh:mykeyspace> delete fname from users where user_id=1745;