我想在表格中插入一个简单的行。有人能指出这里发生了什么吗?
CREATE TABLE recommendation_engine_poc.user_by_category (
game_category text,
customer_id text,
amount double,
game_date timestamp,
PRIMARY KEY (game_category, customer_id)
) WITH CLUSTERING ORDER BY (customer_id ASC)
AND 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'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
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 read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
cqlsh:recommendation_engine_poc> insert into user_by_category ('game_category','customer_id') VALUES ('Goku','12') ;
SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:31 no viable alternative at input 'game_category' (insert into user_by_category (['game_categor]...)">
答案 0 :(得分:16)
语法错误。你在这里:
插入user_by_category(game_category,customer_id)VALUES (&#39;悟空&#39;&#39; 12&#39);
或:
插入user_by_category(&#34; game_category&#34;,&#34; customer_id&#34;)VALUES (&#39; Kakarot&#39;&#39; 12&#39);
第二个通常用于区分大小写的列名称。
答案 1 :(得分:0)
这个问题有两个原因,
所以在使用像 IN 命令这样的过滤器时
从数据库中选择列,其中 column_name IN('xyz','yzx')
单行 IN 命令
它应该在单行而不是
从数据库中选择列,其中 column_name IN('xyz',
'yzx')
多行输入命令