cassandra中的主键是否唯一? [英] Primary key in cassandra is unique?

查看:318
本文介绍了cassandra中的主键是否唯一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能有点la脚,但在cassandra中,主键具有唯一性吗?
例如,在下表中:

It could be kind of lame but in cassandra has the primary key to be unique? For example in the following table:

CREATE TABLE users (
  name text,
  surname text,
  age int,
  adress text,
  PRIMARY KEY(name, surname)
);

因此,如果在我的数据库中数据库中可能有2个人具有相同的名字和姓氏但年龄不同?这意味着相同的主键。

So if is it possible in my database to have 2 persons in my database with the same name and surname but different ages? Which means same primary key..

推荐答案

是的,主键必须唯一。否则,当您使用重复的键进行查询时,将无法知道要返回哪一行。

Yes the primary key has to be unique. Otherwise there would be no way to know which row to return when you query with a duplicate key.

在您的情况下,您可以有两行具有相同的名称或相同的姓氏,但不能同时使用。

In your case you can have 2 rows with the same name or with the same surname but not both.

这篇关于cassandra中的主键是否唯一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆