CQL for Cassandra 1.2

Creating a table

Tables can have single and compound primary keys. To create a table having a single primary key, use the PRIMARY KEY keywords followed by the name of the key, enclosed in parentheses.

Procedure

  1. Create and use the keyspace in the last example if you haven't already done so.
  2. Create this users table in the demodb keyspace, making the user name the primary key.
    CREATE TABLE users (
      user_name varchar,
      password varchar,
      gender varchar,
      session_token varchar,
      state varchar,
      birth_year bigint,
      PRIMARY KEY (user_name));
Show/hide