Search⌘ K

Demo: Reading Data

Explore how to read data from DynamoDB tables by creating sample tables and inserting items. Learn to use query and scan operations to retrieve data efficiently with practice examples to reinforce skills.

Creating a table

Uptill now, we have learnt that we can create a table. For this demo, let’s create a table of medicines. We will keep the “chemical formula” as the partition key and the “dosage” as the sort key. The following is a simple code for creating such a table:

Shell
aws dynamodb create-table \
--table-name Medicines \
--attribute-definitions AttributeName=ChemicalFormula,AttributeType=S \
AttributeName=Dosage,AttributeType=N \
--key-schema AttributeName=ChemicalFormula,KeyType=HASH \
AttributeName=Dosage,KeyType=RANGE \
--provisioned-throughput \
ReadCapacityUnits=4,WriteCapacityUnits=4

Inserting items

Let’s use the bulk-write-item command to insert a few items into our table.

Chemical formula Dosage (mg)
...