Back to Yugabyte Db

YCQL API reference

docs/content/v2.25/api/ycql/_index.md

2026.1.0.0-b256.1 KB
Original Source
<!--menu: v2.25_api: parent: api identifier: api-cassandra weight: 10 params: classes: separator -->

Introduction

Yugabyte Cloud Query Language (YCQL) is a semi-relational SQL API that is best fit for internet-scale OLTP and HTAP applications needing massive data ingestion and blazing-fast queries. It supports strongly consistent secondary indexes, a native JSON column type, and distributed transactions. It has its roots in the Cassandra Query Language (CQL).

This page covers the following YCQL features.

  • Data definition language (DDL) statements.
  • Data manipulation language (DML) statements.
  • Builtin functions and Expression operators.
  • Primitive user-defined data types.

DDL statements

Data definition language (DDL) statements are instructions for the following database operations.

  • Create, alter, and drop database objects
  • Create, grant, and revoke users and roles
StatementDescription
ALTER TABLEAlter a table
ALTER KEYSPACEAlter a keyspace
CREATE INDEXCreate a new index on a table
CREATE KEYSPACECreate a new keyspace
CREATE TABLECreate a new table
CREATE TYPECreate a user-defined data type
DROP INDEXRemove an index
DROP KEYSPACERemove a keyspace
DROP TABLERemove a table
DROP TYPERemove a user-defined data type
USEUse an existing keyspace for subsequent commands

DDL security statements

Security statements are instructions for managing and restricting operations on the database objects.

  • Create, grant, and revoke users and roles
  • Grant, and revoke permissions on database objects

This feature is enabled by setting the YB-TServer configuration flag --use_cassandra_authentication to true.

StatementDescription
ALTER ROLEAlter a role
CREATE ROLECreate a new role
DROP ROLERemove a role
GRANT PERMISSIONGrant a permission on an object to a role
REVOKE PERMISSIONRevoke a permission on an object from a role
GRANT ROLEGrant a role to another role
REVOKE ROLERevoke a role from another role

DML statements

Data manipulation language (DML) statements are used to read from and write to the existing database objects. YugabyteDB implicitly commits any updates by DML statements (similar to how Apache Cassandra behaves).

StatementDescription
INSERTInsert rows into a table
SELECTSelect rows from a table
UPDATEUpdate rows in a table
DELETEDelete specific rows from a table
TRANSACTIONMakes changes to multiple rows in one or more tables in a transaction
TRUNCATERemove all rows from a table

Expressions

An expression is a finite combination of one or more values, operators, functions, and expressions that specifies a computation. Expressions can be used in the following components.

Currently, the following expressions are supported.

ExpressionDescription
Simple ValueColumn, constant, or null. Column alias cannot be used in expression yet.
Subscript []Subscripting columns of collection data types
Operator CallBuiltin operators only
Function CallBuiltin function calls only

Data types

The following table lists all supported primitive types.

Primitive TypeAllowed in KeyType ParametersDescription
BIGINTYes-64-bit signed integer
BLOBYes-String of binary characters
BOOLEANYes-Boolean
COUNTERNo-64-bit signed integer
DECIMALYes-Exact, arbitrary-precision number, no upper-bound on decimal precision
DATEYes-Date
DOUBLEYes-64-bit, inexact, floating-point number
FLOATYes-64-bit, inexact, floating-point number
FROZENYes1Collection in binary format
INETYes-String representation of IP address
INT | INTEGERYes-32-bit signed integer
LISTNo1Collection of ordered elements
MAPNo2Collection of pairs of key-and-value elements
SETNo1Collection of unique elements
SMALLINTYes-16-bit signed integer
TEXT | VARCHARYes-String of Unicode characters
TIMEYes-Time of day
TIMESTAMPYes-Date-and-time
TIMEUUIDYes-Timed UUID
TINYINTYes-8-bit signed integer
UUIDYes-Standard UUID
VARINTYes-Arbitrary-precision integer
JSONBNo-JSON data type similar to PostgreSQL jsonb

User-defined data types are also supported.

Learn more