Apache Cassandra: Starting With Command Line Interface

Starting with Apache Cassandra Command Line Interface

 
The Command Line Interface (CLI) can be used to interact with Apache Cassandra server and execute something that can be done using client code.
 
Now, I'll walk you through some basic operations with Apache Cassandra Command Line Interface (CLI).
 
Step 1: Start the Apache Cassandra Server by running the "<Cassandra_home>\bin\Cassandra.bat" file.
 
Apache-Cassandra-1.jpg 
 
Step 2: Start the Command Line Interface from the "<Cassandra_home>\bin\cassandra-cli.bat" file.
 
Apache-Cassandra-2.jpg 
 
Step 3: Connect your Cassandra CLI with Cassandra Server.
 
Command: connect localhost/9160;
 
Apache-Cassandra-3.jpg 
 
Step 4: Display existing Keyspaces
 
Command to display existing Keyspaces: show keyspaces;
 
Description: It will display all the existing keyspaces in the connected Cassandra server.
 
Apache-Cassandra-4.jpg 
 
Step 5: Creating new keyspace
 
Command to Create a new keyspace: Create keyspace <keyspacename>;
 
For example: create keyspace MuraliKeySpace;
 
Apache-Cassandra-5.jpg 
 
Step 6: Use existing keyspace
 
Command to use an existing keyspace: use <keyspacename>;
 
For example: use MuraliKeySpace;
 
Once you have connected to a keyspace, the default@unknown will be changed to:
 
default@<KeySpaceName>. Now, it is changed to default@MuraliKeySpace.
 
Apache-Cassandra-6.jpg 
 
Step 7: Creating column family
 
Command to create a column family: create column family <ColumnFamilyName>;
 
For example: create column family users;
 
Apache-Cassandra-7.jpg