Open In App

AWS DynamoDB – Update Data in a Table

Amazon DynamoDB is a NoSQL managed database that supports semi-structured data i.e. key-value and document data. A DynamoDB table stores data in the form of an item. While creating a table in DynamoDB, a partition key needs to be defined which acts as the primary key for the table and no schema. Each item consists of attributes. By default, every item will have a partition key as one of the attributes. Every item can have a different number of attributes. An example of an item is given below:

Example:
{
  "Color": true,
  "Director": "Christopher Nolan",
  "MovieID": 1,
  "Name": "Inception",
  "Rating": 8.7,
  "Year": 2010
}

We will be doing the following operations in this article:



  1. Create a table in DynamoDB, say, Movies.
  2. Add items or data into the table.
  3. Update attribute of an item in the table.

The above approach has been implemented below:

Create Table and add Data :



Update Data:

 There are two ways to update the attributes of an item. They are :

Edit MovieID 050

Updated Table 

We observe that the director column of MovieID=050 has been updated with the value ‘Christopher Nolan’. Similarly, we can select any partition key and edit the value of the attribute of an item.

Article Tags :