Imagine you have a table in DynamoDb that looks like this:
Now what if you wanted to add another attribute to a record in the table:
You need to use the
SET function to add the extra address attribute to the record.
Adding New Attribute
To add a new attribute column, use the
UpdateExpression along with
SET to add the new attribute.
Assume that we have already done the
SET attribute is used to add a new attribute to an existing item record.
There are other Update Expressions that can be found in the references section below.
Handling Reserved Characters
In order to add new attribute names that contain reserved characters like hyphens, placeholders have to be used instead.
Placeholders can be alphanumeric.
# placeholder for attribute name and
: placeholder for values.
Expression Attribute Names – https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html
Expression Attribute Values – https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html