Last active
March 2, 2016 06:25
-
-
Save erangaeb/6cc28920c197a03024f7 to your computer and use it in GitHub Desktop.
Cassandra cqlsh
This file contains hidden or 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
# create keyspace | |
create keyspace senz with replication = {'class':'SimpleStrategy','replication_factor':1}; | |
# list all keyspaces | |
describe keyspaces; | |
# drop keyspace | |
drop keyspace <name>; | |
drop keyspace senz; | |
# use keyspace | |
use senz; | |
# show tables in a keyspace | |
describe tables; | |
describe COLUMNFAMILIES; | |
# create table | |
CREATE TABLE user(id INT PRIMARY KEY, username TEXT, address TEXT); | |
# insert to table | |
INSERT INTO user(id, username, address) VALUES(1, 'eranga', 'colombo 03'); | |
# select with partition key | |
SELECT * from user where id = 1; | |
# create secondary index | |
CREATE INDEX usernameIndex on user(username); | |
# select with secondary index | |
SELECT * from user where useranem = 'eranga'; | |
# delete all query | |
TRUNCATE <table name>; | |
TRUNCATE user; | |
# view/describe table strcuture | |
describe <table name>; | |
describe user; | |
# drop table | |
drop table <table name>; | |
drop table user; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment