Jump to main content
DataStax LunaEnterprise Support for Apache Cassandra  —  Start a Free 30-Day Trial Now.
Introduction to Cassandra Query Language
Cassandra Query Language (CQL) is a query language for the Apache Cassandra database.
Data modeling topics.
Data Modeling Concepts
How data modeling should be approached for Apache Cassandra. A music service example is used throughout the CQL document.
Data modeling example
The music service example shows the how to use compound keys, clustering columns, and collections to model Cassandra data.
An index provides a means to access data in Apache Cassandra™ using attributes other than the partition key for fast, efficient lookup of data matching a given condition.
Building and maintaining indexes
Indexes provide operational ease for populating and maintaining the index.
Working with legacy applications
Internally, CQL does not change the row and column mapping from the Thrift API mapping. CQL and Thrift use the same storage engine.
CQL provides an API to Apache Cassandra that is simpler than the Thrift API for new applications.
Starting cqlsh
How to start cqlsh.
Using tab completion
You can use tab completion to see hints about how to complete a cqlsh command.
Creating and updating a keyspace
Creating a keyspace is the CQL counterpart to creating an SQL database.
Creating a table
Steps for creating a table with a single primary key.
Using a user-defined type
An example of creating a user-defined type to attach multiple data fields to a column.
Querying a system table
Details about Apache Cassandra database objects and cluster configuration in the system keyspace tables.
Retrieving and sorting results
Using the SELECT command.
Retrieval using the IN keyword
The IN keyword can define a set of clustering columns to fetch together, supporting a "multi-get" of CQL rows.
Slicing over partition rows
Slicing over rows of a partition when the table has more than one clustering column and comparing groups of clustering keys to certain values.
Batching conditional updates to a static column
An example of batching conditional updates combined with static columns.
Using and misusing batches
When to use batches.
Using the keyspace qualifier
To simplify tracking multiple keyspaces, use the keyspace qualifier instead of the USE statement.
Adding columns to a table
Adding columns to a table with the ALTER TABLE command.
Expiring data
Data in a column, other than a counter column, can have an optional expiration period called TTL (time to live).
Removing a keyspace, schema, or data
Using the DROP and DELETE commands.
Determining the date/time of a write
Using the WRITETIME function in a SELECT statement to determine when the date/time that the column was written to the database.
Altering the data type of a column
Changing the data type of a column after it is defined or added to a table using ALTER TABLE.
Using collections
Collection types provide an improved way of handling tasks, such as building multiple email address capability into tables.
Indexing a column
Using cqlsh to create an index on column values.
Using lightweight transactions
INSERT and UPDATE statements that use the IF clause support lightweight transactions, also known as Compare and Set (CAS).
Paging through unordered partitioner results
Using CQL to page through rows.
Using a counter
A counter is a special column for storing a number that is changed in increments.
Tracing consistency changes
This tutorial shows the difference between these consistency levels and the number of replicas that participate to satisfy a request.
CQL reference topics.
About using CQL.
CQL lexical structure
CQL input consists of statements that change data, look up data, store data, or change the way data is stored.
CQL data types
Built-in data types for columns.
CQL keyspace and table properties
About using CQL keyspace and table properties.
CQL support functions for transforming one or more column values into a new value.
CQL limits
Upper CQL limits.
cqlsh commands
The cqlsh commands.
CQL commands
CQL commands.