Your SlideShare is downloading. ×
CQL - Cassandra commands Notes
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

CQL - Cassandra commands Notes

1,049

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,049
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Cassandra Tutorials – Working in EC2 Cloud:Putty Details:Host name: dev-use1b-pr-33-huginn-dev-0002.prv-openclass.com IP of Cassandra Instance:10.199.240.220 CONNECT TO CASSANDRA INSTANCE:-  cqlsh10.199.240.220 using putty. - To connect to Cassandra instance 10.199.240.220 in EC2 Cloud LIST OF ALL KEYSPACES: Select * from system.system.schema_keyspaces;To get info of all existing keyspaces. Here system is a reserve Cassandra keyspace. WORK IN KEYSPACE: USE sunil_keyspace; To use particular keyspace;
  • 2. DESCRIBE KEYSPACE: Describe keyspacesunil_keyspace; To describe particular keyspace CREATE TABLE: create table users (user_idvarchar, age int, email varchar, city varchar, PRIMARY KEY (user_id)); INSERT RECORDS IN TABLE: insert into users (user_id, age, email, city) values (‘jsmith’, 32, ‘john.smith@example.com’,’Dallas’); To insert records to the table META DATA OF TABLE: describe table users; To get meta data info for particular table.
  • 3. RECORDS OF TABLE: select * from users; To retrieve records from particular table. STRUCTURE OF USERS TABLE:Key Concept:Below is representation of how users table is stored in Cassandra database. KEyspace is container and Table has each rows associated with a primary key. Important point is that a row may contain varied columns as shown in picture.
  • 4. DELETE RECORDS OR PARTICULAR COLUMN: delete email from users where user_id=’sunilk’; This deletes email column from sunilk row in users table. We can see that they appear as null.  select from users where user_id=’sunilk’; Deletes entire row.
  • 5. TRUNCATE:  truncateusers; To delete all records of particular table. But meta data of table is still present. DROP TABLE AND KEYSPACE:  drop table users; To delete both records and meta data. No trace of meta data nor records is found.
  • 6. Sample Facebook Project: Create facebookkeyspace and use facebookkeyspace. Complete list of CQL Data types:-
  • 7.  Create UserProfiles table with following records or rows as seen below.  Updating record of Angela Thomas setting age to 20 and profile picture to 0x5d1b.  For retrieving particular row of table. INDEXES:For non-indexed columns, no output is returned on query. Below is indexing command.
  • 8. ALTER TABLE AND USAGE OF COLLECTION DATATYPES:-

×