Cassandra CLI: provide the primary key name

Is it possible to specify the name of the primary key through the cassandra CLI, for example, through CQL:

create columnfamily test (
  my_key_name varchar primary key,
  value varchar);

By default, cassandra cli creates a primary key named "KEY"

+5
source share
3 answers

The attribute you are looking for key_alias. Unfortunately, you cannot install it through cassandra-cli, only cqlsh. I opened CASSANDRA-4158 to fix this.

+3
source

CLI column_metadata ( ) / . , , test my_key_name , :

update column family test
 with column_metadata =
  [
   {column_name: 'my_key_name', validation_class: UTF8Type, index_type: KEYS}
  ];

update column family test with column_metadata = [];
+1

Here is a CQL example from a Cassandra 1.1 blog post related to blogs on the Datastax website http://www.datastax.com/dev/blog/schema-in-cassandra-1-1

CREATE TABLE users (
    id uuid PRIMARY KEY,
    name varchar,
    state varchar
);

I used only 0.7.x, where you can specify the key data type. Below is the cassandra-cli "help" from 0.7.6; Team

assume <column_family> keys as <type>;

Assume one of the attributes (comparator, sub_comparator, validator or keys)
of the given column family to match specified type. Available types: bytes, integer, long, lexicaluuid, timeuuid, utf8, ascii.
0
source

All Articles