Step 2: Write Data to a Table Using the Console or AWS CLI - Amazon DynamoDB

Step 2: Write Data to a Table Using the Console or AWS CLI

In this step, you insert two items into the Music table that you created in Step 1: Create a Table.

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

Follow these steps to write data to the Music table using the DynamoDB console.

  1. Open the DynamoDB console at https://console.aws.amazon.com/dynamodb/.

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

  3. In the table list, choose the Music table.

  4. Choose the Items tab for the Music table.

  5. On the Items tab, choose Create item.

    
                                Console screenshot showing the Music table and the Create
                                    item button.
  6. Choose the plus sign (+) symbol next to SongTitle.

  7. Choose Append, and then choose Number. Name the field Awards.

    
                                Console screenshot showing the Append list.
  8. Repeat this process to create an AlbumTitle of type String.

  9. Choose the following values for your item:

    1. For Artist, enter No One You Know as the value.

    2. For SongTitle, enter Call Me Today.

    3. For AlbumTitle, enter Somewhat Famous.

    4. For Awards, enter 1.

  10. Choose Save.

    
                                Console screenshot showing the completed fields for the
                                    item.
  11. Repeat this process and create another item with the following values:

    1. For Artist, enter Acme Band.

    2. For SongTitle enter Happy Day.

    3. For AlbumTitle, enter Songs About Life.

    4. For Awards, enter 10.

The following AWS CLI example creates two new items in the Music table using put-item.

aws dynamodb put-item \ --table-name Music \ --item \ '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}' aws dynamodb put-item \ --table-name Music \ --item \ '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"} }'

For more information about supported data types in DynamoDB, see Data Types.

For more information about how to represent DynamoDB data types in JSON, see Attribute Values.

After writing data to your table, proceed to Step 3: Read Data from a Table.