我通过java代码调用cqlsh查询。正在从表中选择key、column1、column2、value、ttl(value)作为ttl的查询。这个很好用。为其激发查询的所有表都有一个名为value的列。但有些表缺少第2列。所以动态地使用上面的查询,如果我能写这样的东西,那就太好了。从表中选择*,ttl(值)作为ttl。但看起来没有办法这么做。我遗漏了什么吗?否则,我将不得不为每个表手动构建查询。
ibps3vxo1#
您将需要动态地构建查询。我们无法选择和附加列。请参考https://cassandra.apache.org/doc/latest/cql/dml.html 选择“查询结构”。它需要“select\u子句”或,而不是两者
select_statement ::= SELECT [ JSON | DISTINCT ] ( select_clause | '*' ) FROM table_name [ WHERE where_clause ] [ GROUP BY group_by_clause ] [ ORDER BY ordering_clause ] [ PER PARTITION LIMIT (integer | bind_marker) ] [ LIMIT (integer | bind_marker) ] [ ALLOW FILTERING ] select_clause ::= selector [ AS identifier ] ( ',' selector [ AS identifier ] ) selector ::= column_name | term | CAST '(' selector AS cql_type ')' | function_name '(' [ selector ( ',' selector )* ] ')' | COUNT '(' '*' ')' where_clause ::= relation ( AND relation )* relation ::= column_name operator term '(' column_name ( ',' column_name )* ')' operator tuple_literal TOKEN '(' column_name ( ',' column_name )* ')' operator term operator ::= '=' | '<' | '>' | '<=' | '>=' | '!=' | IN | CONTAINS | CONTAINS KEY group_by_clause ::= column_name ( ',' column_name )* ordering_clause ::= column_name [ ASC | DESC ] ( ',' column_name [ ASC | DESC ] )*
1条答案
按热度按时间ibps3vxo1#
您将需要动态地构建查询。我们无法选择和附加列。请参考https://cassandra.apache.org/doc/latest/cql/dml.html 选择“查询结构”。它需要“select\u子句”或,而不是两者