Querying a DynamoDB Table
Lab Steps
Introduction
DynamoDB provides two commands for searching data on the table: scan and query. A scan operation examines every item on the table and returns all the data attributes for each one of them. When you initially navigate to the Items tab for a table, a scan is performed by default.
In this lab step, you will practice querying a table.
Instructions
1. In the left-hand menu, click PartiQL editor:
The PartiQL editor page will load.
PartiQL is a SQL (Structured Query Language) compatible language for Amazon DynamoDB. As well as querying tables, you can use it to insert new items and update existing ones.
2. Under Tables, click the three dots next to the and click Scan table:
The Query 1 editor will be populated with a PartiQL query that selects all items from the .
3. To execute the PartiQL table, under the editor, click Run:
4. Scroll down to see the results under Items returned:
Notice that you have a choice of viewing the results in tabular form or in JSON (Java Script Object Notation):
5. To query for a specific item, replace the contents of the Query 1 editor with the following, and click Run:
Copy code
1
SELECT * FROM "Thread" WHERE "Subject" = 'Intro to cool stuff'
This time, you will only see items returned that satisfy the value of the WHERE
condition.
Note: Change the value of the WHERE
condition to match an item you created if you don't see a result.
PartiQL supports most standard features of SQL which means you can query, select, and sort your data in sophisticated ways.
Typically, using the Amazon DynamoDB Console to query items is useful for one-off reports and debugging or troubleshooting. Like most databases, DynamoDB can be accessed programmatically by other systems and software applications through either the AWS SDK (software development kit) or DyanmoDB's HTTP API (application programming interface).
You can learn more about using PartiQL with Amazon DynamoDB by visiting the Working with PartiQL Query Language section of the Amazon DynamoDB developer guide.
Summary
In this lab step, you practiced using the DynamoDB dashboard to query a table.