Cassandra query language (CQL) and Cassandra Java Client Example
Cassandra Table structure/Terminology Before going to learn CQL commands, we just need to know terminology in cassandra. RDBMS Cassandra Terminology Database Keyspace Table Column Family Primary key Row Key Column name Column name Column value column value CQL Commands Creating a key-space
1 2 3 4 |
CREATE keyspace demodb WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 }; CREATE keyspace simpledb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }; |
Use the keyspace (will use that key space)
1 2 |
USE demodb; |
Note: key spaces are equivalent to database/schema in RDBMS Get list of key spaces
1 2 |
DESCRIBE keyspaces; |
Create table
1 2 |
CREATE TABLE users (user_name varchar, password varchar, gender varchar, session_token varchar, state varchar, birth_year bigint, PRIMARY KEY (user_name)); |
Get list […]