Expand on command in Cassandra

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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.