Created
September 11, 2018 04:53
-
-
Save Abhiknoldur/5ba3038db792a113cafd6661b935c5a8 to your computer and use it in GitHub Desktop.
cassandra queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Queries==============> | |
1. CREATE TABLE assignment.emp_details ( | |
emp_id bigint, | |
emp_joining_date date, | |
emp_city text, | |
emp_name text, | |
emp_salary float, | |
PRIMARY KEY (emp_id, emp_joining_date) | |
) WITH CLUSTERING ORDER BY (emp_joining_date DESC); | |
consistency Quorum; | |
2. Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary)values(1,'Name1','Delhi',50000.0,'2018-05-25'); | |
Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary) values(2,'Name2','Noida',60000.0,'2018-05-22'); | |
Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary) values(3,'Name3','Gurgaon',70000.0,'2018-05-25'); | |
Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary) values(4,'Name4','Agra',80000.0,'2018-05-21'); | |
Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary)values(5,'Name5','Matura',90000.0,'2018-05-27'); | |
3. Select * from emp_details wherebemp_id=5; | |
4.Update emp_details set emp_salary=40000, emp_city='chandigarh' WHERE emp_id =5 AND emp_joining_date='2018-05-27'; | |
4. Alter table emp_details add emp_leaving_date date; | |
UPDATE emp_details set emp_leaving_date='2099-01-01' where emp_id IN(1,2,3,4,5); | |
or | |
Alter table emp_details add emp_leaving_date static; | |
Insert into emp_details(emp_id,emp_joining_date,emp_city,emp_name,emp_salary,emp_leaving_date) values(4,'Name4','Agra',80000.0,'2018-05-21','2099-01-01'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cassandra queries