Catalog / Cassandra Query Language (CQL) Cheatsheet
Cassandra Query Language (CQL) Cheatsheet
A quick reference guide to Cassandra Query Language (CQL), covering essential commands, data types, and functions for efficient database management.
Basic CQL Commands
Connecting and Authentication
Connecting to Cassandra:
Example: |
Without Authentication:
Example: |
Keyspace Operations
Create Keyspace: |
Example: |
Use Keyspace: |
Example: |
Alter Keyspace: |
Example: |
Drop Keyspace: |
Example: |
Table Operations
Create Table: |
Example: |
Alter Table (Add Column): |
Example: |
Drop Table: |
Example: |
Truncate Table: |
Example: |
Data Manipulation
Insert Data
Example: |
Select Data
Example: |
Update Data
Example: |
Delete Data
Example: |
Data Types
Common Data Types
text |
Variable-length UTF-8 string. |
ascii |
US-ASCII string. |
bigint |
64-bit signed long. |
blob |
Arbitrary sequence of bytes (up to 2GB). |
boolean |
True or False. |
decimal |
Variable-precision decimal. |
double |
64-bit IEEE-754 floating point. |
float |
32-bit IEEE-754 floating point. |
int |
32-bit signed integer. |
timestamp |
Date and time (stored as milliseconds since epoch). |
uuid |
Type 4 universally unique identifier. |
timeuuid |
Type 1 time-based universally unique identifier. |
inet |
IPv4 or IPv6 address. |
Advanced CQL Features
Indexes
Creating an Index: |
Example: |
Dropping an Index: |
Example: |
Batch Statements
Executing Multiple Statements Atomically:
Example: |
Using Functions
Built-in Functions: |
CQL provides various built-in functions for data manipulation. Examples: |
Example Usage: |
|