Introduction to CQLSH
Now that we are through with the Cassandra setup, let's get acquainted with the shell and a few basic commands:
Run CQL at
/usr/local/Cassandra/apache-cassandra-1.1.6
usingbin/cqlsh
with a host and port:bin/cqlsh –host <ip-adress> -p <port number>
Create a keyspace either at the Cassandra client or at CQL, as follows:
create keyspace <keyspace_name>;
Create a column family at the Cassandra client or at CQL as follows:
use <keyspace_name>; create column family <columnfamily name>;
For example, create the following table:
CREATE TABLE appUSers ( user_name varchar, Dept varchar, email varchar, PRIMARY KEY (user_name));
Insert a few records into the column family from the command line:
INSERT INTO appUSers (user_name, Dept, email) VALUES ('shilpi', 'bigdata, 'shilpisaxena@yahoo.com');
Retrieve the data from the column family:
SELECT * FROM appUSers LIMIT 10;