如何设置 DynamoDB 中字符串字段的最大长度?

Dam*_*ian 2 amazon-dynamodb

你能限制字符串字段的最大长度吗?

该文档仅描述字段的内部限制。

Strings are Unicode with UTF-8 binary encoding. The length of a string must be greater than zero and is constrained by the maximum DynamoDB item size limit of 400 KB.

The following additional constraints apply to primary key attributes that are defined as type string:

For a simple primary key, the maximum length of the first attribute value (the partition key) is 2048 bytes.

For a composite primary key, the maximum length of the second attribute value (the sort key) is 1024 bytes.
Run Code Online (Sandbox Code Playgroud)

mad*_*ead 6

与传统 RDBMS 不同,DynamoDB 没有“最大列大小”的概念。唯一的限制是项目大小限制,正如您所提到的,400 KB。这是一个总限制,它包括属性名称长度和属性值长度。即属性名称也计入总大小限制。

在文档中阅读更多内容。