Cassandra Tutorials – Working in EC2 Cloud:Putty Details:Host name: dev-use1b-pr-33-huginn-dev-0002.prv-openclass.com
IP o...
DESCRIBE KEYSPACE: Describe keyspacesunil_keyspace; To describe particular keyspace

CREATE TABLE: create table users (u...
RECORDS OF TABLE: select * from users; To retrieve records from particular table.

STRUCTURE OF USERS TABLE:Key Concept:B...
DELETE RECORDS OR PARTICULAR COLUMN: delete email from users where user_id=’sunilk’; This deletes email column from sunil...
TRUNCATE:
 truncateusers; To delete all records of particular table. But meta data of table is still present.

DROP TABLE...
Sample Facebook Project: Create facebookkeyspace and use facebookkeyspace.

Complete list of CQL Data types:-
 Create UserProfiles table with following records or rows as seen below.

 Updating record of Angela Thomas setting age ...
ALTER TABLE AND USAGE OF COLLECTION DATATYPES:-
Upcoming SlideShare
Loading in...5
×

CQL - Cassandra commands Notes

1,116

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,116
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CQL - Cassandra commands Notes

  1. 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. 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. 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. 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. 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. 6. Sample Facebook Project: Create facebookkeyspace and use facebookkeyspace. Complete list of CQL Data types:-
  7. 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. 8. ALTER TABLE AND USAGE OF COLLECTION DATATYPES:-

×