0% found this document useful (0 votes)
605 views3 pages

Cassandra Data Handling with cqlsh

The document discusses hands-on exercises for working with Cassandra data handling. It includes examples of creating a keyspace and table, inserting sample data, and creating an index on a table column.

Uploaded by

Girish Sawant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
605 views3 pages

Cassandra Data Handling with cqlsh

The document discusses hands-on exercises for working with Cassandra data handling. It includes examples of creating a keyspace and table, inserting sample data, and creating an index on a table column.

Uploaded by

Girish Sawant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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