• Home
  • Testing
  • SAP
  • Web
  • Must Learn!
  • Big Data
  • Live Projects
  • Blog

Cassandra Data Types

Cassandra supports different types of data types. Here is the table that shows data types, their constants, and description.

CQL Type Constants Description
ascii Strings US-Ascii character string
Bigint Integers 64-bit signed long
Blob Blobs Arbitrary bytes in hexadecimal
Boolean Booleans True or false
Counter Integers Distributed counter values 64 bit
Decimal Integers, floats Variable precision decimal
Double Integers, floats 64-bit floating point
Float Integers, floats 32-bit floating point
Frozen Tuples, collections, user defined types Stores cassandra types
Inet Strings IP address in IPV4 or IPV6 format
Int Integers 32 bit signed integer
List Collection of elements
Map Json style collection of elements
Set Collection of elements
Text Strings UTF-8 encoded strings
Timestamp Integers, strings Id generated with date plus time
Timeuuid Uuids Type 1 uuid
Tuple A group of 2,3 fields
Uuid Uuids Standard uuid
Varchar Strings UTF-8 encoded string
Varint Integers Arbitrary precision integer

Cassandra Automatic Data Expiration

Cassandra provides functionality by which data can be automatically expired.

During data insertion, you have to specify 'ttl' value in seconds. 'ttl' value is the time to live value for the data. After that particular amount of time, data will be automatically removed.

For example, specify ttl value 100 seconds during insertion. Data will be automatically deleted after 100 seconds. When data is expired, that expired data is marked with a tombstone.

A tombstone exists for a grace period. After data is expired, data is automatically removed after compaction process.

Syntax

Insert into KeyspaceName.TableName(ColumnNames) values(ColumnValues)
	using ttl TimeInseconds;

Execution

Here is the snapshot where data is being inserted in Student table with ttl value of 100 seconds.

Cassandra Data Types & Expiration Tutorial

Here is the snapshot where data is automatically expired after 100 seconds and data is automatically removed.

Cassandra Data Types & Expiration Tutorial

 

YOU MIGHT LIKE: