Search⌘ K
AI Features

Native Data Type: Counter

Explore the Counter data type in Apache Cassandra, designed for tracking metrics such as likes and course counts. Understand how to create counter columns, update their values using CQL, and learn the unique rules and limitations of counters including their non-idempotent nature and table design constraints.

We'll cover the following...

As stated earlier, Apache Cassandra is not a schema-less database. It requires the data type for each column to be specified at table definition. This helps validate and restrain the data coming in. The data type dictates how the data is stored on disk, impacting the speed at which it is read and also helps sort data in the correct order. The following diagram illustrates the various categories of data types offered by Apache Cassandra.

Categories of Apache Cassandra data types
Categories of Apache Cassandra data types

For quick reference, the diagram below lists the previously introduced native CQL data types offered by Apache Cassandra.

21 native data types grouped into categories
21 native data types grouped into categories

The counter data type

In this section we will explore the native data type counter. Counters are different from other native data types as they require dedicated tables containing only the table’s primary key and counter column(s).

Counter ...