Developing with CQL

To use Stargate’s Cassandra Query Language (CQL) API you can use the same CQL syntax, tools and native language drivers that you would with a Cassandra deployment.


  • Connect to the cqlsh (CQL shell), either standalone, in the Astra Portal, or as part of a separate Cassandra installation.

    You can also use the CQL API with DataStax drivers.

  • Install cURL.

  • Create a database and set the environment variables for database ID, region, keyspace, and token. For more information, see Create your database.

    1. In the Astra Portal, go to Databases, and then click your database’s name.

    2. Click Connect.

    3. Select your API.

    4. For multi-region databases, select the region to connect to.

    5. Follow the steps to get your application token and set up your environment variables.

Interact with CQL

Add and retrieve schema and data using CQL.

Create a table

CREATE TABLE users_keyspace.users (
    firstname text,
    lastname text,
    email text,
    "favorite color" text,
    PRIMARY KEY (firstname, lastname)

Insert data

INSERT INTO users_keyspace.users (
  "favorite color"

Retrieve data

To select all rows in the table:

SELECT * FROM users_keyspace.users;

To select a row using the primary key:

SELECT * FROM users_keyspace.users WHERE firstname = 'Mookie' AND lastname = 'Betts';

Update data

Update the email address:

UPDATE users_keyspace.users SET email = '' WHERE firstname = 'Mookie' AND lastname = 'Betts';

Verify that the row has the updated email address:

SELECT * FROM users_keyspace.users WHERE firstname = 'Mookie';

Delete data

Delete the row using the primary key:

DELETE FROM users_keyspace.users WHERE firstname = 'Mookie' AND lastname = 'Betts';

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

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: +1 (650) 389-6000,