Cassandra Data Types Cheatsheet
Cassandra has its own query language called CQL (Cassandra Query Language). CQL is similar to SQL in the sense that it stores data in tables containing columns and rows of records.
In this post, we are going to learn more about three different groups of data types in Cassandra: Built-in, Collection, and User-defined data types. .
1. Built-in Data Types
Below is the list of built-in data types that are supported in CQL.
Data Type | Constants | Description |
---|---|---|
ascii | string | ASCII character string |
bigint | integer | 64-bit signed long |
blob | blob | Arbitrary bytes (no validation) expressed as hexadecimal |
boolean | boolean | true or false |
counter | integer | Counter column (64-bit signed value) |
date | integer, string | A date (with no corresponding time value) |
decimal | integer, float | Variable-precision decimal |
double | integer float | 64-bit IEEE-754 floating point |
duration | duration, | A duration with nanosecond precision |
float | integer, float | 32-bit IEEE-754 floating point |
inet | string | An IP address string format, either IPv4 (4 bytes long) or IPv6 (16 bytes long). |
int | integer | 32-bit signed integer |
smallint | integer | 16-bit signed integer |
text | string | UTF-8 encoded string |
time | integer, string | A time (with no corresponding date value) with nanosecond precision, encoded as a 64-bit signed integer |
timestamp | integer, string | A timestamp (date and time) with millisecond precision, encoded as 8 bytes since epoch |
timeuuid | uuid | Version 1 UUID, generally used as a “conflict-free” timestamp |
tinyint | integer | 1 byte integer |
uuid | uuid | A UUID in standard UUID format(of any version) |
varchar | string | UTF8 encoded string |
varint | integer | Arbitrary-precision integer |
2. Collection Data Types
CQL also supports some collection data types
Collection | Description |
---|---|
list | A collection of one or more ordered elements. |
map | A collection of key-value pairs. |
set | A collection of one or more elements. |
Note that these collection data types don’t have constants.
3. User-Defined Data Types
You can create, alter and delete your own data types in Cassandra using these commands:
Command | Description |
---|---|
CREATE TYPE | Create a user-defined datatype. |
ALTER TYPE | Modify a user-defined datatype. |
DROP TYPE | Drop a user-defined datatype. |
DESCRIBE TYPE | Describe a user-defined datatype. |
DESCRIBE TYPES | Describe multiple user-defined datatypes. |
Looking for a good GUI tool to work with Cassandra database? Try TablePlus.
TablePlus is a modern, native client with intuitive GUI tools to create, access, query & edit multiple databases: MySQL, PostgreSQL, SQLite, Microsoft SQL Server, Amazon Redshift, MariaDB, CockroachDB, Vertica, Cassandra, Oracle, and Redis.
It’s free anyway.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS.