The Cassandra Shell
Explore the Cassandra shell cqlsh, and practice executing basic cqlsh commands.
In this lesson, we will cover the Cassandra shell cqlsh
, a command-line interface, provided by Apache Cassandra, which comes installed, located in the bin/
directory. cqlsh
uses Python native protocol driver to connect with a Cassandra node and execute CQL
commands.
To start the CQL shell, type cqlsh
once the cluster is up and running. To connect to a specific host, specify the IP address and port after the cqlsh
keyword. In the absence of a port, the default port 9042 is used for the connection.
cqlsh [options] [host [port]]
Commands exit
or quit
are used to end the current cqlsh
session.
cqlsh
is case insensitive. Soexit
,Exit
orEXIT
are all treated the same.
This course will follow the convention of using uppercase for CQL keywords, and lowercase for other identifiers.
CQL history file
By default, Cassandra maintains a history of all executed CQL commands in the ~/.cassandra/cql_history
file. A different path for the file can be set using the environment variable CQL_HISTORY
. To disable history recording, CQL_HISTORY
can be set to /dev/null
.
CQL shell options
The CQL shell allows several options to be specified for the session after the cqlsh
keyword.
cqlsh [options] [host [port]]
A few key options are listed in the table below:
Short Option | Long Option | Description |
|
| Display |
|
| Display syntax and available options for CQL shell |
|
| Display colored output |
|
| Do not display coloured output |
|
| Connect using the given username |
|
| Connect using the given password |
|
|
|
|
| Execute commands listed in the .cql file and |
|
| Execute the CQL statement provided and |