Cassandra - Cqlsh

This chapter introduces the Cassandra query language shell and explains how to use its commands.
By default, Cassandra provides a prompt Cassandra query language shell (cqlsh) that allows users to communicate with it. Using this shell, you can execute Cassandra Query Language (CQL).
Using cqlsh, you can
define a schema,
insert data, and
execute a query.
Start cqlsh using the command cqlsh as shown below. It gives the Cassandra cqlsh prompt as output.
[hadoop@linux bin]$ cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh>

Cqlsh − As discussed above, this command is used to start the cqlsh prompt. In addition, it supports a few more options as well. The following table explains all the options of cqlsh and their usage.
cqlsh --execute
cql_statement
Cqlsh has a few commands that allow users to interact with it. The commands are
listed below.
Given below are the Cqlsh documented shell commands. These are the commands used to perform tasks such as displaying help topics, exit from cqlsh, describe,etc.
HELP − Displays help topics for all cqlsh commands.
HELP − Displays help topics for all cqlsh commands.
CAPTURE − Captures the output of a command and adds it to a file.
CAPTURE − Captures the output of a command and adds it to a file.
CONSISTENCY − Shows the current consistency level, or sets a new consistency level.
CONSISTENCY − Shows the current consistency level, or sets a new consistency level.
COPY − Copies data to and from Cassandra.
COPY − Copies data to and from Cassandra.
DESCRIBE − Describes the current cluster of Cassandra and its objects.
DESCRIBE − Describes the current cluster of Cassandra and its objects.
EXPAND − Expands the output of a query vertically.
EXPAND − Expands the output of a query vertically.
EXIT − Using this command, you can terminate cqlsh.
EXIT − Using this command, you can terminate cqlsh.
PAGING − Enables or disables query paging.
PAGING − Enables or disables query paging.
SHOW − Displays the details of current cqlsh session such as Cassandra version, host, or data type assumptions.
SHOW − Displays the details of current cqlsh session such as Cassandra version, host, or data type assumptions.
SOURCE − Executes a file that contains CQL statements.
SOURCE − Executes a file that contains CQL statements.
TRACING − Enables or disables request tracing.
TRACING − Enables or disables request tracing.
CREATE KEYSPACE − Creates a KeySpace in Cassandra.
CREATE KEYSPACE − Creates a KeySpace in Cassandra.
USE − Connects to a created KeySpace.
USE − Connects to a created KeySpace.
ALTER KEYSPACE − Changes the properties of a KeySpace.
ALTER KEYSPACE − Changes the properties of a KeySpace.
DROP KEYSPACE − Removes a KeySpace
DROP KEYSPACE − Removes a KeySpace
CREATE TABLE − Creates a table in a KeySpace.
CREATE TABLE − Creates a table in a KeySpace.
ALTER TABLE − Modifies the column properties of a table.
ALTER TABLE − Modifies the column properties of a table.
DROP TABLE − Removes a table.
DROP TABLE − Removes a table.
TRUNCATE − Removes all the data from a table.
TRUNCATE − Removes all the data from a table.
CREATE INDEX − Defines a new index on a single column of a table.
CREATE INDEX − Defines a new index on a single column of a table.
DROP INDEX − Deletes a named index.
DROP INDEX − Deletes a named index.
INSERT − Adds columns for a row in a table.
INSERT − Adds columns for a row in a table.
UPDATE − Updates a column of a row.
UPDATE − Updates a column of a row.
DELETE − Deletes data from a table.
DELETE − Deletes data from a table.
BATCH − Executes multiple DML statements at once.
BATCH − Executes multiple DML statements at once.
SELECT − This clause reads data from a table
SELECT − This clause reads data from a table
WHERE − The where clause is used along with select to read a specific data.
WHERE − The where clause is used along with select to read a specific data.
ORDERBY − The orderby clause is used along with select to read a specific data in a specific order.
ORDERBY − The orderby clause is used along with select to read a specific data in a specific order.

    27 Lectures 
     2 hours 

 Navdeep Kaur

    34 Lectures 
     1.5 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page