Step 4: Update Data in a Table - Amazon DynamoDB

Step 4: Update Data in a Table

In this step, you update an item that you created in Step 2: Write Data to a Table Using the Console or AWS CLI. You can use the DynamoDB console or the AWS CLI to update the AlbumTitle of an item in the Music table by specifying Artist, SongTitle, and the updated AlbumTitle.

For more information about write operations, see Writing an Item.

You can use the DynamoDB console to update data in the Music table.

  1. Open the DynamoDB console at

  2. In the navigation pane on the left side of the console, choose Tables.

  3. Choose the Music table from the table list.

  4. Choose the Items tab for the Music table.

  5. Choose the item whose Artist value is Acme Band and SongTitle value is Happy Day.

  6. Update the AlbumTitle value to Updated Album Title, and then choose Save.

The following image shows the updated item on the console.

                        Console screenshot showing the Edit item page with the updated album
                            title highlighted.

The following AWS CLI example updates an item in the Music table using update-item.

aws dynamodb update-item \ --table-name Music \ --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' \ --update-expression "SET AlbumTitle = :newval" \ --expression-attribute-values '{":newval":{"S":"Updated Album Title"}}' \ --return-values ALL_NEW

Using update-item returns the following sample result.

{ "Attributes": { "AlbumTitle": { "S": "Updated Album Title" }, "Awards": { "N": "10" }, "SongTitle": { "S": "Happy Day" }, "Artist": { "S": "Acme Band" } } }

To query the data in the Music table, proceed to Step 5: Query Data in a Table.