Skip to content
Related Articles

Related Articles

AWS DynamoDB – Read Data from a Table

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 22 Mar, 2021

AWS DynamoDB is a NoSQL managed database that stores semi-structured data i.e. key-value and document data. It stores data in form of an item. An item consists of attributes. Upon table creation in DynamoDB, it only requires a primary key to differentiate between items and no schema is to be defined. Each item can have a different number of attributes. 

Example 1:
  "ArticleID": 1,
  "NameofArticle": "DynamoDB"

Example 2:
  "ArticleID": 3,
  "NameofArticle": "Cloudwatch",
  "Service": "AWS"

To read data from a DynamoDB table, there are 3 ways:

  1. get-item – This is used in AWS Command Line Interface (CLI). To retrieve an item you must specify a table name and keys that you want to retrieve.
  2. Query – The items in the table can be retrieved by querying on the table. While querying, it by default contains the primary key as a search filter. More attributes can be added to refine search.
  3. Scan – It is similar to the query. The only difference is that it doesn’t have any attribute by default for searching. To search an item, you must define an attribute, and its value to find the item.


  • Create Table and Items: To read data from a table, the table and data inside the table should exist. In this example, a table named geeksforgeeks has already been created with few items inside it. See the below image:

Read Data from Table:

To read data through Amazon Console we have two ways.

  • Scan Method: To use the scan method, select Scan from the dropdown. Then in the filter add one attribute. In this example, we want all the articles written by Rohan Chopra. Therefore, add attribute WrittenBy as the filter and enter the value as ‘Rohan Chopra’. Click on start search to get results. See the below image:

  • Query Method – To use the query method, select Query from the dropdown. By default, we will have our partition key as one search filter. We can add more attributes in the filter to refine our search. In the following image, we see that partition key ArticleID is already present. But we also add one more search filter i.e. Service.

The following image is of the invalid query. The query contains ArticleID=2 and Service=’AWS‘. 

We see that the item ArticleID=2 does not have any attribute as Service. Therefore, no records were found.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!