我是Cassandra和noSQL数据库的初学者。为了考试,我必须纠正教授给我的一些指导。我已经纠正了其中一些问题,但现在我无法解决此问题:
cqlsh> create COLUMNFAMILY post
... with comparator = UTF8Type
... and read_repair_chance = 0.1
... and keys_cached = 100
... and gc_grace = 0
... and min_compaction_threshold = 5
... and max_compaction_threshold = 31
我从CLI收到此错误:
SyntaxException: line 2:0 mismatched input 'with' expecting '(' (create COLUMNFAMILY post[with] comparator...)
如果有人可以帮助我,我将非常感激。
我希望这是可以理解的,因为我的英语不是很好
您的列族定义或表定义(这是Cassandra表的最新术语)缺少实际的列和主键,似乎您已将列定义(比较器= UTF8Type)与表选项混合在一起,例如为read_repair_chance和gc_grace_period。
所有Cassandra表必须至少具有一个主键列。
要使用默认表选项在键空间post
中创建最小表ks
,您可以这样做:
CREATE TABLE ks.post (comparator text PRIMARY KEY);
检查表定义和设置表选项的完整语法:
describe table ks.post;
CREATE TABLE ks.post (
comparator text PRIMARY KEY
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND speculative_retry = '99PERCENTILE';
注意:如果使用默认表选项,则不必在表创建命令中指定它们。
有关表创建的文档,请在此处查看示例:https://docs.datastax.com/en/dse/5.1/cql/cql/cql_reference/cql_commands/cqlCreateTable.html
或这里:http://cassandra.apache.org/doc/latest/cql/ddl.html#create-table