Step 3: Read Data from a Table - Amazon DynamoDB

Step 3: Read Data from a Table

In this step, you will read back an item that was 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 read an item from the Music table by specifying Artist and SongTitle.

For more information about read operations in DynamoDB, see Reading an Item.

Follow these steps to read data from 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. Choose the Music table from the table list.

  4. Choose the Items tab for the Music table.

  5. On the Items tab, view the list of items stored in the table, sorted by Artist and SongTitle.

    The first item in the list is the one with the Artist Acme Band and the SongTitle Happy Day.

    
                                Console screenshot showing the items list with Acme Band at
                                    the top of the list.

The following AWS CLI example reads an item from the Music table using get-item.

Note

The default behavior for DynamoDB is eventually consistent reads. The consistent-read parameter is used below to demonstrate strongly consistent reads.

aws dynamodb get-item --consistent-read \ --table-name Music \ --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}'

Using get-item returns the following sample result.

{ "Item": { "AlbumTitle": { "S": "Songs About Life" }, "Awards": { "N": "10" }, "SongTitle": { "S": "Happy Day" }, "Artist": { "S": "Acme Band" } } }

To update the data in your table, proceed to Step 4: Update Data in a Table.