Damian
Damian

Reputation: 3050

How to set max length for a String field in DynamoDB?

Can you constrain the max length of a string field?

The documentation describes only the internal limits for a field.

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.

Upvotes: 2

Views: 9700

Answers (1)

madhead
madhead

Reputation: 33422

Unlike traditional RDBMS, DynamoDB does not have a notion of "maximal column size". The only limit is an item size limit, which is, as you've mentioned, 400 KB. That is a total limit, it inludes attribute name lenghts and attribute value lengths. I.e. the attribute names also counts towards the total size limit.

Read more in the docs.

Upvotes: 7

Related Questions