如何在cassandra中定义动态列族 [英] How to define dynamic column families in cassandra
问题描述
这里是说,没有特殊的努力需要得到一个动态列族。但我总是得到一个异常,当我尝试为一个未定义的列设置一个值。
Here it is said, that no special effort is need to get a dynamic column family. But I always get an exception, when I try to set a value for an undefined column.
我创建了一个这样的列族:
I created a column family like this:
CREATE TABLE places (
latitude double,
longitude double,
name text,
tags text,
PRIMARY KEY (latitude, longitude, name)
)
定义标签列。有人可以解释我为什么吗?也许是因为所有其他列都是索引的一部分?
BTW: I had to define the tags column. Can somebody explain me why? Maybe because all other columns are part of the Index?
现在当插入如下数据时:
Now when inserting data like this:
INSERT INTO places ("latitude","longitude","name","tags") VALUES (49.797888,9.934771,'Test','foo,bar')
它工作正常!但是当我尝试时:
it works just fine! But when I try:
INSERT INTO places ("latitude","longitude","name","tags","website") VALUES (49.797888,9.934771,'Test','foo,bar','test.de')
$ b b
我得到以下错误:
I get following error:
Bad Request: Unknown identifier website
text could not be lexed at line 1, char 21
需要进行哪些更改才能动态添加列?
Which changes are needed so I can dynamically add columns?
我使用Cassandra 1.1.9和CQL3直接在服务器上使用cqlsh。
I am using Cassandra 1.1.9 with CQL3 with the cqlsh directly on a server.
推荐答案
CQL3支持动态列族,但是你必须先修改表格模式
CQL3 supports dynamic column family but you have to alter the table schema first
ALTER TABLE places ADD website varchar;
这篇关于如何在cassandra中定义动态列族的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!