Setting a table property

Using the WITH clause and keyword arguments for configure caching, compaction, and other operations that Apache Cassandra performs on new table.

Using the optional WITH clause and keyword arguments, you can configure caching, compaction, and a number of other operations that Apache Cassandra performs on new table. You can use the WITH clause to specify the properties of tables listed in CQL table properties, including caching, table comments, compression, and compaction. Format the property as either a string or a map. Enclose a string property in single quotation marks. For example, to embed a comment in a table, you format the comment as a string property:

CREATE TABLE MonkeyTypes (
  block_id uuid,
  species text,
  alias text,
  population varint,
  PRIMARY KEY (block_id)
)
WITH comment='Important biological records'
AND read_repair_chance = 1.0;
  

To configure compression and compaction, you use property maps:

CREATE TABLE DogTypes (
  block_id uuid,
  species text,
  alias text,
  population varint,
  PRIMARY KEY (block_id)
) WITH compression =
    { 'sstable_compression' : 'DeflateCompressor', 'chunk_length_kb' : 64 }
  AND compaction =
    { 'class' : 'SizeTieredCompactionStrategy', 'min_threshold' : 6 };

To specify using compact storage or clustering order use the WITH clause.

To configure caching in Cassandra 2.1, you also use a property map.

// Cassandra 2.1

CREATE TABLE DogTypes (
             ...   block_id uuid,
             ...   species text,
             ...   alias text,
             ...   population varint,
             ...   PRIMARY KEY (block_id)
             ... ) WITH caching = '{ 'keys' : 'NONE', 'rows_per_partition' : '120' }';