Search⌘ K

Static Columns

Explore how static columns function in Apache Cassandra to store data shared across all rows within a partition. Understand their syntax, use cases, and constraints, including how to add static columns, insert and update their data, and query them effectively. This lesson helps you optimize table design and storage in Cassandra, especially for tables with multiple clustering columns.

We'll cover the following...

Static columns

Recall the syntax for CREATE TABLE statement:

PostgreSQL
CREATE TABLE [IF NOT EXISTS] [keyspaceName.]tableName (
column_name cql_type [ STATIC ] [, ...]
PRIMARY KEY (column_name [, column_name ...])
)
[ WITH table_options ] ;

Please refer to syntax conventions for CQL syntax notation details.

In Cassandra, a static column is defined by adding the STATIC keyword after the column data type, at the end of a column definition.

column_name cql_type STATIC

For example, the following line defines a static column titled profile_link:

profile_link text STATIC

Static columns ...