CQL quick reference

A consolidated syntax list of Cassandra Query Language (CQL) commands for quick reference.

Cassandra Query Language (CQL) commands are divided into four categories:

This quick reference provides a consolidated list of Cassandra Query Language (CQL) commands along with their syntax for easy reference.

Data definition language (DDL)

Don’t execute multiple DDL commands at the same time. Concurrent schema changes can result in nodes having different schemas. These inconsistencies cannot be resolved by normal repair operations.

ALTER TABLE [<keyspace_name>.]<table_name>
  [ ADD ( <column_definition> | <column_definition_list> ) [ , ... ] ]
  [ DROP <column_name> [ , ... ] ]
  [ RENAME <column_name> TO <column_name> ];
ALTER TYPE
ALTER TYPE <field_name>
  ( ADD <field_name> <cql_datatype>
  | RENAME <field_name> TO <<<new_field_name> [ AND <field_name> TO <new_field_name> ...] ) ;
CREATE INDEX
CREATE [CUSTOM] INDEX [ IF NOT EXISTS ] [ <index_name> ]
  ON [<keyspace_name>.]<table_name>
  ([ KEYS | VALUES | ENTRIES | FULL] <column_name>)
    USING <index_type>
  [ WITH OPTIONS = { <option_map> } ] ;
CREATE TABLE
CREATE TABLE [ IF NOT EXISTS ] [<keyspace_name>.]<table_name>
( <column_definition> [ , ... ]
  [ , PRIMARY KEY ( ( <partition_key_column_name> [ , ... ] )
                  [ , ( <clustering_column_name> [ ... ] ) ] ) ] )
  [ [ WITH | AND ] <table_options> ]
  [ [ WITH | AND ] CLUSTERING ORDER BY ( <clustering_column_name> [ ASC | DESC ] [ , ... ] ) ] ;
CREATE TYPE
CREATE TYPE [ IF NOT EXISTS ] [<keyspace_name>].<type_name>
  (<field_name> <cql_datatype> [ , <field_name> <cql_datatype> ... ]) ;
DROP INDEX
DROP INDEX [ IF EXISTS ] [<keyspace_name>.]<index_name> ;
DROP TABLE
DROP TABLE [ IF EXISTS ] [<keyspace_name>.]<table_name> ;
DROP TYPE
DROP TYPE [ IF EXISTS ] [<keyspace_name>.]<type_name> ;
REBUILD SEARCH INDEX
REBUILD SEARCH INDEX ON <keyspace_name>.]<table_name>
  [ WITH OPTIONS { deleteAll : ( true | false ) } ] ;
RELOAD SEARCH INDEX
RELOAD SEARCH INDEX ON [<keyspace_name>.]<table_name> ;
TRUNCATE
TRUNCATE [ TABLE ] [<keyspace_name>.]<table_name> ;

Data manipulation language (DML)

BATCH
BEGIN [ ( UNLOGGED | LOGGED ) ] BATCH
  [ USING TIMESTAMP [ <epoch_microseconds> ] ]
  <dml_statement> [ USING TIMESTAMP [ <epoch_microseconds> ] ] ;
  [ <dml_statement> [ USING TIMESTAMP [ <epoch_microseconds> ] ] [ ; ... ] ] ;
  APPLY BATCH ;
DELETE
DELETE [ <column_name> [ <term> ] [ , ... ] ]
  FROM [<keyspace_name>.]<table_name>
  [ USING TIMESTAMP <timestamp_value> ]
  WHERE <PK_column_conditions>
  [ ( IF EXISTS | IF <static_column_conditions> ) ] ;
INSERT
INSERT [ JSON ] INTO [<keyspace_name>.]<table_name>
  [ <column_list> VALUES <column_values> ]
  [ IF NOT EXISTS ]
  [ USING [ TTL <seconds> ] [ [ AND ] TIMESTAMP <epoch_in_microseconds> ] ] ;
SELECT
SELECT [ JSON | DISTINCT ] <selectors>
  FROM [<keyspace_name>.]<table_name>
  [ WHERE [ <primary_key_conditions> | <non_primary_key_conditions> IN (<column_name> [, ...]) ALLOW FILTERING ] [ AND ] [ <index_conditions> ]
  [ GROUP BY <column_name> [ , ... ] ]
  [ ORDER BY <column_name> ( ASC | DESC ) [ , ... ] ] |
  [ ORDER BY <vector_column_name> ANN OF [n,n,n,...] [ LIMIT N ] ]
  [ ( LIMIT <N> [ OFFSET <N> ]  | PER PARTITION LIMIT <N> ) ]
  [ ALLOW FILTERING ] ;
UPDATE
UPDATE [<keyspace_name>.]<table_name>
  [ USING TTL <time_value> ]
  [ [ AND ] USING TIMESTAMP <timestamp_value> ]
  SET <assignment> [ , <assignment> ... ]
  WHERE <row_specification>
  [ IF EXISTS | IF <condition> [ AND <condition> ] ] ;

Data control language (DCL)

Astra DB does not suport CQL DCL commands. Use the Astra Portal to manage database users and roles.

Session/Utility commands

USE
USE <keyspace_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