Database Operations

For a NoSQL, Cassandra seems more as SQL Database (Oracle, DB2, etc) than NoSQL databases (Mongo for example) A lot of the commands are the same as SQL datatabase, as you will see below:

Connection

First and foremost, we have to connect to our cassandra :) Cassandra uses a lot of ports and knowing which ports to use is essential:

Cassandra

7199 JMX monitoring port and in earlier Cassandra (0.8) version it was 8080

9042 CQL Native Transport Port

9160 Thrift client API

7000 Inter-node cluster

7001 TLS Internode communication (used if TLS enabled)

DataStax OpsCenter

61620 opscenterd daemon

61621 Agent

8888 Website

So for our connection we will use port: 9042, which is the native CQL client port, as follows:

Schemas/Databases

Schemas/Databases, also known as keyspaces, are created as follows:

Table

Tables, also known as column families, are created within a schema/database as follows:

Insert

Inserts are also done pretty easily:

Create users

Users in Cassandra can have either super(all privileges) role or objects privileges for objects. In order to list all the users, use the following command:

List Users

To create new user, we can do as follows:

Create users