DynamoDb范围键可以为空吗? [英] Can DynamoDb range key be empty?

查看:120
本文介绍了DynamoDb范围键可以为空吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的一个应用程序使用DynamoDb。

I am looking at using DynamoDb for one of my applications.

我想知道是否可以将属性设置为范围键,然后将其保留为空某些记录(为空或为空)。

I wanted to know if it's possible to set an attribute as range key and then leave it unpopulated for certain records(either empty or null).

推荐答案

您不能插入带有范围键作为空值或没有空格的项目范围键。

You can't insert an item with Range Key as empty value or without the Range key.

如果不包含范围键。您将得到以下错误:-

If the Range key is not included. You would get the below error:-

"One of the required keys was not given a value"

如果Range键中填充了''(即空字符串)

If the Range key is populated with '' (i.e. empty string)

"message": "One or more parameter values were invalid: An AttributeValue may not contain an empty string"

从AWS Doc:-


添加项目时,主键属性( s)是唯一的
必需属性。属性值不能为null。 String和
二进制类型属性的长度必须大于零。设置类型
属性不能为空。具有空值的请求将被
拒绝,并带有ValidationException异常。

When you add an item, the primary key attribute(s) are the only required attributes. Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes cannot be empty. Requests with empty values will be rejected with a ValidationException exception.

这篇关于DynamoDb范围键可以为空吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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