In this tutorial, we will learn about the cqlsh commands. In Cassandra, cqlsh commands can be used through CQL interactive terminal. These commands will work only within the Cqlsh shell.

SHOW VERSION – This command will show you the cqlsh, Cassandra, CQL, and native protocol versions.

Example:

 

SHOW HOST – This command will give you the IP address and port number, cluster name.

Example:

 

SOURCE – This command allow you to read the contents of a file and executes CQL statements in the file.

Syntax:

Example:

 

CAPTURE – This command will capture the command output and append to a mentioned file.

Syntax:

 

HELP – This command will provide us the information about cqlsh commands.

TRACING – This Command Enables or disables tracing in cqlsh command prompt.

Syntax:

 

PAGING – This command enables or disables paging, or set the page size. This will be helpful when we have large content as output.

Syntax:

 

EXPAND – This command enables or disables vertical printing of rows. Enabling EXPAND is useful when many columns are fetched.

Syntax:

 

LOGIN – This command Authenticate the Cassandra user for the current session.

Syntax:

 

EXIT – This command will end the current session and terminates the cqlsh process.

Syntax:

 

CLEAR – This command clears the console.

Syntax:

 

DESCRIBE – This command gives the description of all below Schema Elements.

Syntax:

Example:

COPY TO – This command copies data from a table to a CSV file.

Syntax:

 

Note:

If we need specific columns , then we need to specify the column list, Otherwise it will copy all columns from the table to the CSV file.