Open In App

Expand on command in Cassandra

Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Cassandra
In this article, we are going to discuss cqlsh shell command like expand on, expand off, describe keyspace, describe the table and also discuss with implemented cqlsh query.

First, we are going to create keyspace in cqlsh. Below given is cqlsh Query for creating a keyspace.

create keyspace cluster1
with REPLICATION = {'class' : 'SimpleStrategy', 
                    'replication_factor':'1'}; 

Now, after successfully created cluter1 keyspace. we are going to use it for creating a table.

use cluster1;

cqlsh:cluster1> create table inbox_search
 (
  key_id UUID primary key,
  keyword_name text,
  status text
 ); 

Now, we are going to insert some data into the table(inbox_search).

Insert into inbox_search(key_id, keyword_name, status)
values(uuid(), 'inbox', 'active');

Insert into inbox_search(key_id, keyword_name, status)
values(uuid(), 'profile', 'ok');

Insert into inbox_search(key_id, keyword_name, status)
values(uuid(), 'Ashish', 'done'); 

Now, to verify the results see the output and implemented cqlsh query given below.

To verify the keyspace used the following cqlsh query.

To verify the table used the following cqlsh query.

To verify the use keyspace command used the following cqlsh query.

Now, we are going to discuss expand on command in cqlsh. expand on command is used to expanding the results into separate rows. let’s have a look.

Now, we can also use expand off command to not expand the results and In general, Expand off is by default. given below is an implemented cqlsh query to verify the results of how it works.


Last Updated : 20 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads