Cassandra
Cassandra Collection: Set, List, Map with Example
What is Cassandra Collections? Cassandra collections are a good way for handling tasks. Multiple...
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 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;
Example
Here is the snapshot where data is being inserted in Student table with ttl value of 100 seconds.
insert into University.Student(rollno,name,dept,semester) values(3,'gtupapers','CS’,7) using ttl 100;
Here is the snapshot where data is automatically expired after 100 seconds and data is automatically removed.
What is Cassandra Collections? Cassandra collections are a good way for handling tasks. Multiple...
$20.20 $9.99 for today 4.6 (119 ratings) Key Highlights of Cassandra PDF 94+ pages eBook Designed...
In this article, you will learn- Cassandra Create Keyspace Alter Keyspace Drop/Delete Keyspace How...
Cassandra Create Index Command 'Create index' creates an index on the column specified by the...
There are two types of security in Apache Cassandra and Datastax enterprise. Internal...
The syntax of Cassandra query language (CQL) resembles with SQL language. Create Table Alter Table...