在 CQL3 之前,可以插入任意列,例如以日期命名的列:
cqlsh:test>CREATE TABLE seen_ships (day text PRIMARY KEY)
WITH comparator=timestamp AND default_validation=text;
cqlsh:test>INSERT INTO seen_ships (day, '2013-02-02 00:08:22')
VALUES ('Tuesday', 'Sunrise');
根据这篇文章,CQL3 中的情况似乎有所不同。是否仍然可以插入任意列?这是我失败的尝试:
cqlsh:test>CREATE TABLE seen_ships (
day text,
time_seen timestamp,
shipname text,
PRIMARY KEY (day, time_seen)
);
cqlsh:test>INSERT INTO seen_ships (day, 'foo') VALUES ('Tuesday', 'bar');
我在这里得到Bad Request: line 1:29 no viable alternative at input 'foo'
所以我尝试了一个稍微不同的表,因为这可能是复合键的限制:
cqlsh:test>CREATE TABLE seen_ships ( day text PRIMARY KEY );
cqlsh:test>INSERT INTO seen_ships (day, 'foo') VALUES ('Tuesday', 'bar');
再次与Bad Request: line 1:29 no viable alternative at input 'foo'
我在这里想念什么?