Is it possible to specify a name of primary key via cassandra CLI, like via CQL:
create columnfamily test (
my_key_name varchar primary key,
value varchar);
By default, cassandra cli creates primary key with name 'KEY'
The attribute you're looking for is key_alias
. Unfortunately, you can't currently set it through cassandra-cli, only cqlsh. I've opened CASSANDRA-4158 to fix this.
When creating or updating a column family via the CLI, you can specify the column_metadata to identify the type (validation class) and/or if the column has an index. e.g., assuming you have created the test column family, and wish to specify the column my_key_name as string type which is indexed:
update column family test
with column_metadata =
[
{column_name: 'my_key_name', validation_class: UTF8Type, index_type: KEYS}
];
if you wanted to later drop the index
update column family test with column_metadata = [];
Here is a CQL example from a Cassandra 1.1 schema related blog post 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 have used only 0.7.x where you can specify the data type of the key. Following is from 0.7.6 cassandra-cli "help assume;" command
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.