CQLSH Commands

CQLSH Commands

If we are connecting to an external Cassandra such as Apache Cassandra we may need a way to search for records stored under specific key spaced. Below commands will be helpful for us to obtain these details

Step1
/apache-cassandra-2.0.9/bin

./cqlsh -ucassandra -pcassandra

for a remote server
 ./cqlsh <server-ip> 9160 -ucassandrauser -pcassandrapw
 


This will take us to the cqlsh command prompt as below

Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.9 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh>

Step2
To view key spaces

describe keyspaces;

cqlsh> describe keyspaces;

BAM_UTIL_KS  system  EVENT_KS  EVENT_INDEX_KS  system_traces

cqlsh>

Step 3
Select a specific key space use use "EVENT_KS";


To list out the column families under the keyspace

describe columnfamilies;

ASStream                            bam_service_data_publisher_new    
JMSStream                           hl7_data_publisher_def            
MQTTSteram                          http_stream                       
bam_activity_data_publisher_new     jmx_agent_toolbox                 
bam_hl7_data_publisher_store        org_wso2_bam_phone_retail_store_kpi
bam_mediation_stats_data_publisher  org_wso2_ticket_service           
bam_service_data_publisher          person                            
bam_service_data_publisher_2        products   


Step 5
To get a row count 

cqlsh:EVENT_KS> select count(*) from "bam_hl7_data_publisher_store" LIMIT 100000000;

 count
--------
 146594

(1 rows)

Note: we can give a large value for limit because the default limit is Default LIMIT of 10000 and if you have more records you may not be able to see the results.

Comments