You are on page 1of 3

CASSANDRA DATA HANDLING HANDS

ON

1. Cassandra Data Handling - Cyclist Details Updated

CODE: Write the below code in Terminal


cqlsh
cqlsh>CREATE KEYSPACE cycling WITH
replication={'class':'SimpleStrategy','replication_factor':3};
cqlsh> USE cycling;
cqlsh:cycling> CREATE TABLE cyclist_details(id int PRIMARY KEY,name text);
cqlsh:cycling> INSERT INTO cyclist_details(id,name) VALUES(1,'Raichel');
cqlsh:cycling> INSERT INTO cyclist_details(id,name) VALUES(2,'Alex');
cqlsh:cycling> INSERT INTO cyclist_details(id,name) VALUES(3,'Ellen');

COPY cyclist_details(id,name) TO './cyclers.csv' WITH HEADER=True;

Click on “Run”>TEST

2) Cassandra Data Handling - Index Updated

Write the below Code to pass the Hands On


cqlsh

cqlsh> CREATE KEYSPACE my_index WITH


REPLICATION={'class':'SimpleStrategy',replication_factor:3};
cqlsh> CREATE KEYSPACE my_index WITH
REPLICATION={'class':'SimpleStrategy','replication_factor':3};
cqlsh> USE my_index;
cqlsh:my_index> CREATE TABLE riders(id int PRIMARY KEY,name text,phoneno int,location
text);
cqlsh:my_index> INSERT INTO riders(id,name,phoneno,location)
VALUES(1,'Alex',12345,'Syria');
cqlsh:my_index> INSERT INTO riders(id,name,phoneno,location)
VALUES(2,'Ellen',23451,'Paris');
cqlsh:my_index> INSERT INTO riders(id,name,phoneno,location)
VALUES(3,'Jiva',34512,'Italy');
cqlsh:my_index> INSERT INTO riders(id,name,phoneno,location)
VALUES(4,'Minie',45123,'Europe');
cqlsh:my_index> INSERT INTO riders(id,name,phoneno,location)
VALUES(5,'Humpty',51234,'Houston');
cqlsh:my_index> CREATE INDEX riders_location ON riders(location);

Now click on RUN->TEST to see the results

You might also like