Apache Cassandra™ 1.2

Creating a table

Defining a static and a dynamic tables.

In this procedure, you define a static table, a table having designated column names, and a dynamic table. In a static table, most rows have approximately the same columns. The settings of comparator, key_validation_class, and validation_class set the default encoding used for column names, row key values and column values. In the case of column names, the comparator also determines the sort order.


  1. Connect to the keyspace where you want to define the table.
    [default@unknown] USE demo;
  2. Define a table having full_name, email, state, gender, and birth_year columns.
    [default@demo] CREATE COLUMN FAMILY users
                     WITH comparator = UTF8Type
                     AND key_validation_class=UTF8Type
                     AND column_metadata = [
                     {column_name: full_name, validation_class: UTF8Type}
                     {column_name: email, validation_class: UTF8Type}
                     {column_name: state, validation_class: UTF8Type}
                     {column_name: gender, validation_class: UTF8Type}
                     {column_name: birth_year, validation_class: LongType}
  3. Create a dynamic table called blog_entry. Notice that here we do not specify column definitions as the column names are expected to be supplied later by the client application.
    [default@demo] CREATE COLUMN FAMILY blog_entry
                     WITH comparator = TimeUUIDType
                     AND key_validation_class=UTF8Type
                     AND default_validation_class = UTF8Type;

Attention: Be sure this document version matches your product version