SOURCE

Executes a file containing CQL statements.

The output of each statement is shown in the standard output (STDOUT), including error messages. You can use IF NOT EXISTS to suppress errors for some statements, such as CREATE KEYSPACE. All statements in the file are executed, even if a no-operation error occurs.

Synopsis

SOURCE '<file_name>'
<file_name>

Name of the file to execute. Specify the path of the file relative to the current directory, which is the directory where CQL shell was started on your local machine. Enclose the file name in single quotation marks. Use tilde (~) for your home directory.

Examples

Execute CQL statements from a file:

SOURCE '~/cycling_setup/create_ks_and_tables.cql'

To execute a CQL file without starting a shell session, use bin/cqlsh --file '<file_name>'.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use |  Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM