加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cassandra ::我可以创建一个没有主键的表吗?

发布时间:2020-12-13 13:29:25 所属栏目:百科 来源:网络整理
导读:现在我正在学习Cassandra,所以我得到了一张没有主键的桌子.但它有一些指数. 所以这是我的疑问,我可以创建一个没有主键的表. CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid varchar,operatorproductid varchar,pric
现在我正在学习Cassandra,所以我得到了一张没有主键的桌子.但它有一些指数.

所以这是我的疑问,我可以创建一个没有主键的表.

CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid varchar,operatorproductid varchar,price float,fallback varchar,paymenttype varchar,operatorid varchar,subscriptiontype varchar,expiry timestamp,subscriptionstatus varchar,created timestamp);

没有主键,subscriberid,productid,operatorid和subscriptiontype是索引.这可能吗?

从文档中

Primary Key::
A primary key identifies the location and order of data storage. The primary key is defined at table creation
time and cannot be altered. If the primary key must be changed,a new table schema is created and the
data is written to the new table. Cassandra is a partition row store,and a component of the primary key,
the partition key,identifies which node will hold a particular table row.
At the minimum,the primary key must consist of a partition key. Composite partition keys can split a
data set so that related data is stored on separate partitions. Compound primary keys include clustering
columns which order the data on a partition.
The definition of a table’s primary key is critical in Cassandra. Carefully model how data in a table will
be inserted and retrieved before choosing which columns will define the primary key. The size of the
partitions,the order of the data within partitions,the distribution of the partitions amongst the nodes of the
cluster – all of these considerations determine selection of the best primary key for a table.

解决方法

简单的答案是否定的,主键是强制性的

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读