Jump to main content
DataStax LunaEnterprise Support for Apache Cassandra  —  Start a Free 30-Day Trial Now.
About CQL
CQL (Cassandra Query Language) is a query language for the DataStax Distribution of Apache Cassandra database.
Quickstart for CQL.
Introduction to CQL and data modeling.
Running CQL commands
Run CQL commands using CQL shell.
Data modeling
Introduction to data modeling.
Creating a keyspace
Add a keyspace and set the replication factor.
Creating a table with a simple primary key
Create a table with a simple primary key and populate it with data.
Creating a table with a compound primary key
Create a table with a compound primary key and populate it with data.
Creating a table with a composite partition key
Create a table with a composite partition key and populate it with data.
Using a secondary index
Create a secondary index on a column.
Updating data
The UPDATE statement writes one or more column values to a row.
Deleting and truncating data
The DELETE statement removes data from one or more columns, or removes an entire row. The TRUNCATE statement removes all data from a table.
Dropping tables and keyspaces
The DROP TABLE statement removes a table and the table data. The DROP KEYSPACE statement removes the keyspace and all of the objects in the keyspace.
Increase your knowledge
Increase your knowledge of CQL and data modeling.
CQL quick reference
Provides a consolidated syntax list of Cassandra Query Language (CQL) commands for quick reference.
Basic rules to follow when designing a DataStax Distribution of Apache Cassandra database.
Data modeling concepts
Uses a Pro Cycling example to demonstrate the query-driven approach to data modeling.
Data modeling analysis
Analyze the design based on storage, capacity, redundancy, and consistency.
Using materialized views
Learn about materialized views, which are tables with data that is automatically inserted and updated from another base table.
Shows the CQL command syntax and rules, and provides instruction on using CQL shell (cqlsh).
Accessing data using CQL
Common ways to access data include cqlsh, drivers, and DataStax Studio.
Understanding the CQL command syntax
Basic rules and limitations for writing CQL statements; including case, valid characters, escaping characters, keyspace qualifiers, commenting, keywords, and exponential notation.
Create and drop keyspaces. Manage the replication factor (data availability).
About keyspaces
Top level database object that contains tables, materialized views, user-defined types, functions, and aggregates and controls the data replication factor.
Creating a keyspace
Add a new keyspace and set the replication factor.
Modifying the replication factor
Increasing the replication factor increases the total number of copies of keyspace data stored in a cluster.
Dropping a keyspace
Remove a keyspace and all the database objects it contains.
About system keyspace tables
Provides details about database objects and cluster configuration in the system keyspace tables.
Create, replace, alter, and drop customized user-defined functions, aggregates, and types.
Creating user-defined function (UDF)
Write custom functions using Java and other programming languages for use in SELECT, INSERT, and UPDATE statements.
Creating User-Defined Aggregate Function (UDA)
User-Defined Aggregates (UDAs) can be used to manipulate stored data across rows of data, returning a result that is further manipulated by a final function.
Modifying a user-defined type
Adding columns to a user-defined type with the ALTER TYPE command.
Dropping a user-defined function (UDF)
How to use the DROP command to delete a user-defined function (UDF).
How to create tables to store data.
Creating a table
How to create CQL tables.
Creating a counter table
A counter is a special column for storing a number that is changed in increments.
Creating a table with COMPACT STORAGE
Create a table that is compatible with the legacy (Thrift) storage engine format.
Fixing a table schema collision
How to fix schema collision problems.
Altering a table
Add or delete columns and change table properties.
Dropping a table
Steps for dropping a keyspace or table using the DROP command.
Indexing tables
How to query data from tables using indexes.
Retrieve data sets from a table using SELECT statements.
About SELECT statements
Retrieving data from tables.
Setting consistency levels
Set the consistency level to control the accuracy of the data returned by read request.
Restricting queries using WHERE clauses
Describes restrictions of partition and clustering columns in WHERE clause.
Sorting and limiting results
Using the SELECT command for simple queries.
Returning collections
How to retrieve data from a collection.
Aggregating results
Using the SELECT command to return data and apply standard aggregate functions.
Using user-defined functions (UDF)
Using the SELECT command to return data and applying a UDF.
Returning the write timestamp
Using the WRITETIME function in a SELECT statement to determine when the date/time that the column was written to the database.
Formatting query results as JSON
Use the SELECT command to return JSON data.
Legacy tables
How to work with legacy tables.
How to insert data into a table with either regular or JSON data.
Using INSERT and UPDATE to write values
Inserting set data with the INSERT command.
Using lightweight transactions
INSERT and UPDATE statements that use the IF clause support lightweight transactions, also known as Compare and Set (CAS).
Inserting JSON formatted values
Inserting JSON data with the INSERT command for testing queries.
Importing data from a CSV file
Inserting data with the cqlsh command COPY from a CSV file is common for testing queries.
Deleting values
Use the DELETE command to replace the value in a column with null or to remove an entire row of data.
Expiring data with time-to-live
Use time-to-live (TTL) to expire data in a column or table.
Performing multiple writes in the same command.
Batching inserts, updates, and deletes
Batching inserts, updates, and deletes.
Good use of BATCH statement
How to use a BATCH statement.
Misuse of BATCH statement
How to misuse a BATCH statement.
CQL reference topics.
About using CQL.
CQL data types
Describes CQL column types.
CQL native functions
Describes scalar functions that work on values in a single row of data to create a new value.
CQL native aggregates
Works on a set of rows matching the SELECT statement to return a single value.
cqlsh reference
Commands specific to the Cassandra Query Language shell (cqlsh) utility.
CQL commands
CQL commands.
CQL commands to set up the cycling examples used in this guide.
Cycling tables
CQL commands that create cycling example tables and insert the corresponding data.