ScyllaDB University LIVE, FREE Virtual Training Event | March 21
Register for Free
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB Open Source ScyllaDB for Administrators Admin Tools CQLSh: the CQL shell

Caution

You're viewing documentation for a previous version. Switch to the latest stable version.

CQLSh: the CQL shell¶

cqlsh is a command line shell for interacting with ScyllaDB through CQL (the Cassandra Query Language). It is shipped with every ScyllaDB package and can be found in the bin/ directory. In addition, it is available on Docker Hub and in the Python Package Index (PyPI).

cqlsh utilizes the Python native protocol driver and connects to the single node specified on the command line.

See the scylla-cqlsh repository on GitHub for usage examples.

Compatibility¶

cqlsh is compatible with Python 3.8 - Python 3.11.

A given version of cqlsh is only guaranteed to work with the version of ScyllaDB that it was released with. cqlsh may work with older or newer versions of ScyllaDB without any guarantees.

Optional Dependencies¶

cqlsh ships with all essential dependencies. However, there are some optional dependencies that can be installed to improve the capabilities of cqlsh.

pytz¶

By default, cqlsh displays all timestamps with a UTC timezone. To support display of timestamps with another timezone, the pytz library must be installed. See the timezone option in cqlshrc for specifying a timezone to use.

cython¶

The performance of cqlsh’s COPY operations can be improved by installing cython. This will compile the python modules that are central to the performance of COPY.

cqlshrc¶

The cqlshrc file holds configuration options for cqlsh. By default, this is in the user’s home directory:

~/.cassandra/cqlsh, but a custom location can be specified with the --cqlshrc option.

Example config values and documentation can be found in the conf/cqlshrc.sample file of a tarball installation. You can also view the latest version of cqlshrc online.

Command Line Options¶

Usage:

cqlsh [options] [host [port]]

Options:

-C --color

Force color output

--no-color

Disable color output

--browser

Specify the browser to use for displaying cqlsh help. This can be one of the supported browser names (e.g. firefox) or a browser path followed by %s (e.g. /usr/bin/google-chrome-stable %s).

--ssl

Use SSL when connecting to ScyllaDB.

-u --user

Username to authenticate against ScyllaDB.

-p --password

The password to authenticate against ScyllaDB, which should be used in conjunction with --user

-k --keyspace

Keyspace to authenticate to should be used in conjunction with --user

-f --file

Execute commands from the given file, then exit

--debug

Print additional debugging information

--encoding

Specify a non-default encoding for output (defaults to UTF-8)

--cqlshrc

Specify a non-default location for the cqlshrc file

-e --execute

Execute the given statement, then exit

--connect-timeout

Specify the connection timeout in seconds (defaults to 2s)

--request-timeout

Specify the request timeout in seconds (defaults to 10s)

-t --tty

Force tty mode (command prompt)

Special Commands¶

In addition to supporting regular CQL statements, cqlsh also supports a number of special commands that are not part of CQL. These are detailed below.

CONSISTENCY¶

Usage: CONSISTENCY <consistency level>

Sets the consistency level for operations to follow. Valid arguments include:

- ANY
- ONE
- TWO
- THREE
- QUORUM
- ALL
- LOCAL_QUORUM
- LOCAL_ONE
- SERIAL
- LOCAL_SERIAL

SERIAL CONSISTENCY¶

Usage: SERIAL CONSISTENCY <consistency level>

Sets the serial consistency level for operations to follow. Valid arguments include:

  • SERIAL

  • LOCAL_SERIAL

The serial consistency level is only used by conditional updates (INSERT, UPDATE, and DELETE with an IF condition). For those, the serial consistency level defines the consistency level of the serial phase (or “paxos” phase) while the normal consistency level defines the consistency for the “learn” phase, i.e. what type of reads will be guaranteed to see the update right away. For example, if a conditional write has a consistency level of QUORUM (and is successful), then a QUORUM read is guaranteed to see that write. However, if the regular consistency level of that write is ANY, then only a read with a consistency level of SERIAL is guaranteed to see it (even a read with consistency ALL is not guaranteed to be enough).

SHOW VERSION¶

This command is useful if you want to check which Cassandra version is compatible with your ScyllaDB version. Note that the two standards are not 100% identical and this command is simply a comparison tool.

If you want to display your current ScyllaDB version, refer to Check your current version of ScyllaDB.

The display shows:

  • The cqlsh tool version that you’re using

  • The Apache Cassandra version that your version of ScyllaDB is most compatible with

  • The CQL protocol standard that your version of ScyllaDB is most compatible with

  • The native protocol standard that your version of ScyllaDB is most compatible with

Example:

cqlsh> SHOW VERSION

Returns:

[cqlsh 5.0.1 | Cassandra 3.0.8 | CQL spec 3.3.1 | Native protocol v4]

SHOW HOST¶

Prints the IP address and port of the ScyllaDB node that cqlsh is connected to in addition to the cluster name.

Example:

cqlsh> SHOW HOST

Returns:

Connected to Prod_Cluster at 192.0.0.1:9042.

SHOW SESSION¶

Pretty prints a specific tracing session.

Usage: SHOW SESSION <session id>

Example usage:

cqlsh> SHOW SESSION 95ac6470-327e-11e6-beca-dfb660d92ad8

Returns:

Tracing session: 95ac6470-327e-11e6-beca-dfb660d92ad8

 activity                                                  | timestamp                  | source    | source_elapsed | client
-----------------------------------------------------------+----------------------------+-----------+----------------+-----------
                                        Execute CQL3 query | 2016-06-14 17:23:13.979000 | 127.0.0.1 |              0 | 127.0.0.1
 Parsing SELECT * FROM system.local; [SharedPool-Worker-1] | 2016-06-14 17:23:13.982000 | 127.0.0.1 |           3843 | 127.0.0.1
...

SOURCE¶

Reads the contents of a file and executes each line as a CQL statement or special cqlsh command.

Usage: SOURCE <string filename>

Example usage:

cqlsh> SOURCE '/home/thobbs/commands.cql'

CAPTURE¶

Begins capturing command output and appending it to a specified file. Output will not be shown at the console while it is captured.

Usage:

CAPTURE '<file>';
CAPTURE OFF;
CAPTURE;

That is, the path to the file to be appended to must be given inside a string literal. The path is interpreted relative to the current working directory. The tilde shorthand notation ('~/mydir') is supported for referring to $HOME.

Only query result output is captured. Errors and output from cqlsh-only commands will still be shown in the cqlsh session.

To stop capturing output and show it in the cqlsh session again, use CAPTURE OFF.

To inspect the current capture configuration, use CAPTURE with no arguments.

HELP¶

Gives information about cqlsh commands. To see available topics, enter HELP without any arguments. To see help on a topic, use HELP <topic>. Also, see the --browser argument for controlling what browser is used to display help.

TRACING¶

Enables or disables tracing for queries. When tracing is enabled, once a query completes, a trace of the events during the query will be printed.

Usage:

TRACING ON
TRACING OFF

PAGING¶

Enables paging, disables paging, or sets the page size for read queries. When paging is enabled, only one page of data will be fetched at a time, and a prompt will appear to fetch the next page. Generally, it’s a good idea to leave paging enabled in an interactive session to avoid fetching and printing large amounts of data at once.

Usage:

PAGING ON
PAGING OFF
PAGING <page size in rows>

EXPAND¶

Enables or disables vertical printing of rows. Enabling EXPAND is useful when many columns are fetched, or the contents of a single column are large.

Usage:

EXPAND ON
EXPAND OFF

LOGIN¶

Authenticate as a specified ScyllaDB user for the current session.

Usage:

LOGIN <username> [<password>]

EXIT¶

Ends the current session and terminates the cqlsh process.

Usage:

EXIT
QUIT

CLEAR¶

Clears the console.

Usage:

CLEAR
CLS

DESCRIBE¶

Prints a description (typically a series of DDL statements) of a schema element or the cluster. This is useful for dumping all or portions of the schema.

DESCRIBE CLUSTER
DESCRIBE SCHEMA
DESCRIBE KEYSPACES
DESCRIBE KEYSPACE <keyspace name>
DESCRIBE TABLES
DESCRIBE TABLE <table name>
DESCRIBE MATERIALIZED VIEW <view name>
DESCRIBE TYPES
DESCRIBE TYPE <type name>
DESCRIBE FUNCTIONS
DESCRIBE FUNCTION <function name>
DESCRIBE AGGREGATES
DESCRIBE AGGREGATE <aggregate function name>

In any of the commands, DESC may be used in place of DESCRIBE.

You may also omit what you want to describe and just simply use DESCRIBE <name>. This will look for the object

in a specific order: keyspace, table, view, index, user-defined type, user-defined function, user-defined aggregate.

The DESCRIBE CLUSTER command prints the cluster name and partitioner:

cqlsh> DESCRIBE CLUSTER

Cluster: Test Cluster
Partitioner: Murmur3Partitioner

The DESCRIBE SCHEMA command prints the DDL statements needed to recreate the entire schema. This is especially useful for dumping the schema in order to clone a cluster or restore from a backup.

COPY TO¶

Copies data from a table to a CSV file.

COPY <table name> [(<column>, ...)] TO <file name> WITH <copy option> [AND <copy option> ...]

If no columns are specified, all columns from the table will be copied to the CSV file. A subset of columns to copy may be specified by adding a comma-separated list of column names surrounded by parenthesis after the table name.

The <file name> should be a string literal (with single quotes) representing a path to the destination file. The file name can also contain the special value STDOUT (without single quotes) print the CSV to STDOUT.

See Shared COPY Options for options that apply to both COPY TO and COPY FROM.

Options for COPY TO¶

MAXREQUESTS

The maximum number token ranges to fetch simultaneously. Defaults to 6.

PAGESIZE

The number of rows to fetch in a single page. Defaults to 1000.

PAGETIMEOUT

By default, the page timeout is 10 seconds per 1000 entries in the page size or 10 seconds if pagesize is smaller.

BEGINTOKEN, ENDTOKEN

Token range to export. Defaults to exporting the full ring.

MAXOUTPUTSIZE

The maximum size of the output file measured in number of lines; beyond this maximum the output file will be split into segments. -1 means unlimited, and is the default.

ENCODING

The encoding used for characters. Defaults to utf8.

COPY FROM¶

Copies data from a CSV file to table.

COPY <table name> [(<column>, ...)] FROM <file name> WITH <copy option> [AND <copy option> ...]

If no columns are specified, all columns from the CSV file will be copied to the table. A subset of columns to copy may be specified by adding a comma-separated list of column names surrounded by parenthesis after the table name.

The <file name> should be a string literal (with single quotes) representing a path to the source file. The file name can also contain the special value``STDIN`` (without single quotes) to read the CSV data from STDIN.

See Shared COPY Options for options that apply to both COPY TO and COPY FROM.

Options for COPY FROM¶

INGESTRATE

The maximum number of rows to process per second. Defaults to 100000.

MAXROWS

The maximum number of rows to import. -1 means unlimited, and is the default.

SKIPROWS

A number of initial rows to skip. Defaults to 0.

SKIPCOLS

A comma-separated list of column names to ignore. By default, no columns are skipped.

MAXPARSEERRORS

The maximum global number of parsing errors to ignore. -1 means unlimited, and is the default.

MAXINSERTERRORS

The maximum global number of insert errors to ignore. -1 means unlimited. The default is 1000.

ERRFILE =

A file to store all rows that could not be imported. By default, this is import_<ks>_<table>.err where <ks> is your keyspace and <table> is your table name.

MAXBATCHSIZE

The max number of rows inserted in a single batch. Defaults to 20.

MINBATCHSIZE

The min number of rows inserted in a single batch. Defaults to 2.

CHUNKSIZE

The number of rows that are passed to child worker processes from the main process at a time. Defaults to 1000.

Shared COPY Options¶

Options that are common to both COPY TO and COPY FROM.

NULLVAL

The string placeholder for null values. Defaults to null.

HEADER

For COPY TO, controls whether the first line in the CSV output file will contain the column names. For COPY FROM, specifies whether the first line in the CSV input file contains column names. Defaults to false.

DECIMALSEP

The character that is used as the decimal point separator. Defaults to ..

THOUSANDSSEP

The character that is used to separate thousands. Defaults to the empty string.

BOOLSTYlE

The string literal format for boolean values. By default this is True, False.

NUMPROCESSES

The number of child worker processes to create for COPY tasks. Defaults to a max of 4 for COPY FROM and 16 for COPY TO. However, at most (num_cores - 1), processes will be created.

MAXATTEMPTS

The maximum number of failed attempts to fetch a range of data (when using COPY TO) or insert a chunk of data (when using COPY FROM) before giving up. Defaults to 5.

REPORTFREQUENCY

How often status updates are refreshed in seconds. By default, this is 0.25 seconds.

RATEFILE

An optional file to export rate statistics to. By default, this is disabled and statistics are not exported to a file.

See also:

CQLSH lesson on ScyllaDB University

  • Apache Cassandra Query Language (CQL) Reference

Back

Copyright

© 2016, The Apache Software Foundation.

Apache®, Apache Cassandra®, Cassandra®, the Apache feather logo and the Apache Cassandra® Eye logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.

Was this page helpful?

PREVIOUS
Nodetool version
NEXT
Admin REST API
  • Create an issue
  • Edit this page

On this page

  • CQLSh: the CQL shell
    • Compatibility
    • Optional Dependencies
      • pytz
      • cython
    • cqlshrc
    • Command Line Options
    • Special Commands
      • CONSISTENCY
      • SERIAL CONSISTENCY
      • SHOW VERSION
      • SHOW HOST
      • SHOW SESSION
      • SOURCE
      • CAPTURE
      • HELP
      • TRACING
      • PAGING
      • EXPAND
      • LOGIN
      • EXIT
      • CLEAR
      • DESCRIBE
      • COPY TO
        • Options for COPY TO
      • COPY FROM
        • Options for COPY FROM
        • Shared COPY Options
ScyllaDB Open Source
  • 6.2
    • master
    • 6.2
    • 6.1
    • 6.0
    • 5.4
    • 5.2
    • 5.1
  • Getting Started
    • Install ScyllaDB
      • Launch ScyllaDB on AWS
      • Launch ScyllaDB on GCP
      • Launch ScyllaDB on Azure
      • ScyllaDB Web Installer for Linux
      • Install ScyllaDB Linux Packages
      • Install scylla-jmx Package
      • Run ScyllaDB in Docker
      • Install ScyllaDB Without root Privileges
      • Air-gapped Server Installation
      • ScyllaDB Housekeeping and how to disable it
      • ScyllaDB Developer Mode
    • Configure ScyllaDB
    • ScyllaDB Configuration Reference
    • ScyllaDB Requirements
      • System Requirements
      • OS Support by Linux Distributions and Version
      • Cloud Instance Recommendations
      • ScyllaDB in a Shared Environment
    • Migrate to ScyllaDB
      • Migration Process from Cassandra to ScyllaDB
      • ScyllaDB and Apache Cassandra Compatibility
      • Migration Tools Overview
    • Integration Solutions
      • Integrate ScyllaDB with Spark
      • Integrate ScyllaDB with KairosDB
      • Integrate ScyllaDB with Presto
      • Integrate ScyllaDB with Elasticsearch
      • Integrate ScyllaDB with Kubernetes
      • Integrate ScyllaDB with the JanusGraph Graph Data System
      • Integrate ScyllaDB with DataDog
      • Integrate ScyllaDB with Kafka
      • Integrate ScyllaDB with IOTA Chronicle
      • Integrate ScyllaDB with Spring
      • Shard-Aware Kafka Connector for ScyllaDB
      • Install ScyllaDB with Ansible
      • Integrate ScyllaDB with Databricks
      • Integrate ScyllaDB with Jaeger Server
      • Integrate ScyllaDB with MindsDB
    • Tutorials
  • ScyllaDB for Administrators
    • Administration Guide
    • Procedures
      • Cluster Management
      • Backup & Restore
      • Change Configuration
      • Maintenance
      • Best Practices
      • Benchmarking ScyllaDB
      • Migrate from Cassandra to ScyllaDB
      • Disable Housekeeping
    • Security
      • ScyllaDB Security Checklist
      • Enable Authentication
      • Enable and Disable Authentication Without Downtime
      • Creating a Custom Superuser
      • Generate a cqlshrc File
      • Reset Authenticator Password
      • Enable Authorization
      • Grant Authorization CQL Reference
      • Certificate-based Authentication
      • Role Based Access Control (RBAC)
      • Encryption: Data in Transit Client to Node
      • Encryption: Data in Transit Node to Node
      • Generating a self-signed Certificate Chain Using openssl
      • Configure SaslauthdAuthenticator
    • Admin Tools
      • Nodetool Reference
      • CQLSh
      • Admin REST API
      • Tracing
      • ScyllaDB SStable
      • ScyllaDB Types
      • SSTableLoader
      • cassandra-stress
      • SSTabledump
      • SSTableMetadata
      • ScyllaDB Logs
      • Seastar Perftune
      • Virtual Tables
      • Reading mutation fragments
      • Maintenance socket
      • Maintenance mode
      • Task manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
    • ScyllaDB Manager
    • Upgrade Procedures
      • ScyllaDB Versioning
      • ScyllaDB Open Source Upgrade
      • ScyllaDB Open Source to ScyllaDB Enterprise Upgrade
      • ScyllaDB Image
      • ScyllaDB Enterprise
    • System Configuration
      • System Configuration Guide
      • scylla.yaml
      • ScyllaDB Snitches
    • Benchmarking ScyllaDB
    • ScyllaDB Diagnostic Tools
  • ScyllaDB for Developers
    • Develop with ScyllaDB
    • Tutorials and Example Projects
    • Learn to Use ScyllaDB
    • ScyllaDB Alternator
    • ScyllaDB Drivers
      • ScyllaDB CQL Drivers
      • ScyllaDB DynamoDB Drivers
  • CQL Reference
    • CQLSh: the CQL shell
    • Appendices
    • Compaction
    • Consistency Levels
    • Consistency Level Calculator
    • Data Definition
    • Data Manipulation
      • SELECT
      • INSERT
      • UPDATE
      • DELETE
      • BATCH
    • Data Types
    • Definitions
    • Global Secondary Indexes
    • Expiring Data with Time to Live (TTL)
    • Functions
    • Wasm support for user-defined functions
    • JSON Support
    • Materialized Views
    • Non-Reserved CQL Keywords
    • Reserved CQL Keywords
    • Service Levels
    • ScyllaDB CQL Extensions
  • Alternator: DynamoDB API in Scylla
    • Getting Started With ScyllaDB Alternator
    • ScyllaDB Alternator for DynamoDB users
  • Features
    • Lightweight Transactions
    • Global Secondary Indexes
    • Local Secondary Indexes
    • Materialized Views
    • Counters
    • Change Data Capture
      • CDC Overview
      • The CDC Log Table
      • Basic operations in CDC
      • CDC Streams
      • CDC Stream Generations
      • Querying CDC Streams
      • Advanced column types
      • Preimages and postimages
      • Data Consistency in CDC
    • Workload Attributes
  • ScyllaDB Architecture
    • Data Distribution with Tablets
    • ScyllaDB Ring Architecture
    • ScyllaDB Fault Tolerance
    • Consistency Level Console Demo
    • ScyllaDB Anti-Entropy
      • ScyllaDB Hinted Handoff
      • ScyllaDB Read Repair
      • ScyllaDB Repair
    • SSTable
      • ScyllaDB SSTable - 2.x
      • ScyllaDB SSTable - 3.x
    • Compaction Strategies
    • Raft Consensus Algorithm in ScyllaDB
    • Zero-token Nodes
  • Troubleshooting ScyllaDB
    • Errors and Support
      • Report a ScyllaDB problem
      • Error Messages
      • Change Log Level
    • ScyllaDB Startup
      • Ownership Problems
      • ScyllaDB will not Start
      • ScyllaDB Python Script broken
    • Upgrade
      • Inaccessible configuration files after ScyllaDB upgrade
    • Cluster and Node
      • Handling Node Failures
      • Failure to Add, Remove, or Replace a Node
      • Failed Decommission Problem
      • Cluster Timeouts
      • Node Joined With No Data
      • NullPointerException
      • Failed Schema Sync
    • Data Modeling
      • ScyllaDB Large Partitions Table
      • ScyllaDB Large Rows and Cells Table
      • Large Partitions Hunting
      • Failure to Update the Schema
    • Data Storage and SSTables
      • Space Utilization Increasing
      • Disk Space is not Reclaimed
      • SSTable Corruption Problem
      • Pointless Compactions
      • Limiting Compaction
    • CQL
      • Time Range Query Fails
      • COPY FROM Fails
      • CQL Connection Table
    • ScyllaDB Monitor and Manager
      • Manager and Monitoring integration
      • Manager lists healthy nodes as down
    • Installation and Removal
      • Removing ScyllaDB on Ubuntu breaks system packages
  • Knowledge Base
    • Upgrading from experimental CDC
    • Compaction
    • Consistency in ScyllaDB
    • Counting all rows in a table is slow
    • CQL Query Does Not Display Entire Result Set
    • When CQLSh query returns partial results with followed by “More”
    • Run ScyllaDB and supporting services as a custom user:group
    • Customizing CPUSET
    • Decoding Stack Traces
    • Snapshots and Disk Utilization
    • DPDK mode
    • Debug your database with Flame Graphs
    • How to Change gc_grace_seconds for a Table
    • Gossip in ScyllaDB
    • Increase Permission Cache to Avoid Non-paged Queries
    • How does ScyllaDB LWT Differ from Apache Cassandra ?
    • Map CPUs to ScyllaDB Shards
    • ScyllaDB Memory Usage
    • NTP Configuration for ScyllaDB
    • Updating the Mode in perftune.yaml After a ScyllaDB Upgrade
    • POSIX networking for ScyllaDB
    • ScyllaDB consistency quiz for administrators
    • Recreate RAID devices
    • How to Safely Increase the Replication Factor
    • ScyllaDB and Spark integration
    • Increase ScyllaDB resource limits over systemd
    • ScyllaDB Seed Nodes
    • How to Set up a Swap Space
    • ScyllaDB Snapshots
    • ScyllaDB payload sent duplicated static columns
    • Stopping a local repair
    • System Limits
    • How to flush old tombstones from a table
    • Time to Live (TTL) and Compaction
    • ScyllaDB Nodes are Unresponsive
    • Update a Primary Key
    • Using the perf utility with ScyllaDB
    • Configure ScyllaDB Networking with Multiple NIC/IP Combinations
  • Reference
    • AWS Images
    • Azure Images
    • GCP Images
    • Configuration Parameters
    • Glossary
    • Limits
    • API Reference (BETA)
    • Metrics (BETA)
  • ScyllaDB FAQ
  • Contribute to ScyllaDB
Docs Tutorials University Contact Us About Us
© 2025, ScyllaDB. All rights reserved. | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 08 May 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.6