0
0
DynamoDBquery~5 mins

Basic scan operation in DynamoDB

Choose your learning style9 modes available
Introduction

A basic scan operation reads every item in a DynamoDB table. It helps you see all the data stored without any filters.

You want to get all the records from a small table to see what data it holds.
You need to export all data from a table for backup or analysis.
You want to quickly check the contents of a table during development.
You want to count how many items are in a table without conditions.
You want to retrieve all items before applying filters in your application code.
Syntax
DynamoDB
aws dynamodb scan \
  --table-name TableName \
  [--filter-expression FilterExpression] \
  [--projection-expression Attributes] \
  [--limit Number]

The Scan command reads every item in the table.

You can add filters to reduce returned items, but the scan still reads all data internally.

Examples
Scan the entire 'Music' table and return all items.
DynamoDB
aws dynamodb scan --table-name Music
Scan 'Music' table but only return items where Artist is 'No One You Know'.
DynamoDB
aws dynamodb scan --table-name Music --filter-expression "Artist = :artist" --expression-attribute-values '{":artist":{"S":"No One You Know"}}'
Scan 'Music' table but return only the SongTitle and AlbumTitle attributes.
DynamoDB
aws dynamodb scan --table-name Music --projection-expression "SongTitle, AlbumTitle"
Sample Program

This command scans the entire 'Books' table and returns all items stored in it.

DynamoDB
aws dynamodb scan --table-name Books
OutputSuccess
Important Notes

Scan reads every item, so it can be slow and costly on large tables.

Use FilterExpression to reduce returned data but scan still reads all items.

For large tables, consider using queries or indexes for better performance.

Summary

Scan reads all items in a DynamoDB table.

It is simple but can be slow for big tables.

Use filters to limit returned data but scan still reads everything internally.