问题 - 我能够使用 CQL2 中不存在的列值的 select 语句检索结果(但这在 CQL3 中不会发生);谁可以给我解释一下这个 ?
您知道为什么我的选择查询会得到一个不存在的 C0 列值(“测试”)的结果吗? 我不明白——见下文: 一定有什么配置错误,但是什么?
cqlsh> use Keyspace1;
cqlsh:Keyspace1> CREATE COLUMNFAMILY users (
... KEY varchar PRIMARY KEY,
... gender varchar,
... birth_year bigint);
cqlsh:Keyspace1> INSERT INTO users (KEY, gender, birth_year) VALUES ('TEST', 'm', 1968);
cqlsh:Keyspace1> select * from users;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> select * from users where key = 'TEST';
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> CREATE INDEX birth_year_key ON users (birth_year);
cqlsh:Keyspace1> CREATE INDEX gender_key ON users (gender);
cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1968;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> select * from users where birth_year = 1968;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
到目前为止,一切顺利,但现在观看:
cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1962;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
这里发生了什么事? 谢谢, 马特
最佳答案
对我来说听起来像是 CQL2 中的一个错误。
事情是这样的:基本上,CQL2 仍然存在的唯一原因是为了让针对它编写的少数应用程序能够继续工作。不会添加任何新功能,也不会修复任何错误(因为这可能会导致其他地方的回归)。
因此,如果您正在构建新应用程序,则绝对应该使用 CQL3。不要将 CQL2 视为任何有意义的替代方案。请参阅http://www.datastax.com/dev/blog/cql3-for-cassandra-experts详分割析了 CQL2 的缺点,正是这些缺点促使我们创建了 CQL3 作为替代品。
关于cassandra - Cassandra CQL2 中的 Select 语句不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15990822/