2012-04-13 113 views
5

名称是否有可能通过卡桑德拉CLI指定主键的名称,通过CQL,如:卡桑德拉CLI:指定的主键

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

默认情况下,卡桑德拉CLI创建名称为“KEY”

主键

回答

3

您要查找的属性是key_alias。不幸的是,你目前无法通过cassandra-cli来设置它,只有cqlsh。我打开了CASSANDRA-4158来解决这个问题。

0

下面是从Datastax网站上卡桑德拉1.1架构相关的博客文章CQL例如 http://www.datastax.com/dev/blog/schema-in-cassandra-1-1

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

我只用0.7.x您可以在其中指定密钥的数据类型。以下是从0.7.6 cassandra-cli“帮助承担”;命令

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. 
1

创建或通过CLI更新列族时,可以指定column_metadata标识类型(验证类)和/或如果该列的索引。 例如,假设你已经创建了测试列族,并希望指定列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 = [];