0
0
DynamoDBquery~5 mins

First table creation in DynamoDB

Choose your learning style9 modes available
Introduction
Creating a table is the first step to store and organize your data in DynamoDB.
When you want to save user information like names and emails.
When you need to keep track of products in an online store.
When you want to store logs or events from an application.
When you want to organize data by categories or IDs for quick access.
Syntax
DynamoDB
aws dynamodb create-table \
    --table-name TableName \
    --attribute-definitions AttributeName=KeyName,AttributeType=Type \
    --key-schema AttributeName=KeyName,KeyType=KeyType \
    --provisioned-throughput ReadCapacityUnits=Number,WriteCapacityUnits=Number
Replace TableName with your table's name.
AttributeType can be S (string), N (number), or B (binary).
Examples
Creates a table named 'Users' with 'UserID' as the primary key.
DynamoDB
aws dynamodb create-table \
    --table-name Users \
    --attribute-definitions AttributeName=UserID,AttributeType=S \
    --key-schema AttributeName=UserID,KeyType=HASH \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Creates a table named 'Products' with a numeric primary key 'ProductID'.
DynamoDB
aws dynamodb create-table \
    --table-name Products \
    --attribute-definitions AttributeName=ProductID,AttributeType=N \
    --key-schema AttributeName=ProductID,KeyType=HASH \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10
Sample Program
This command creates a DynamoDB table called 'Books' where each book is identified by its ISBN number.
DynamoDB
aws dynamodb create-table \
    --table-name Books \
    --attribute-definitions AttributeName=ISBN,AttributeType=S \
    --key-schema AttributeName=ISBN,KeyType=HASH \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
OutputSuccess
Important Notes
The table status will be 'CREATING' right after creation and changes to 'ACTIVE' when ready.
You must choose a primary key to uniquely identify each item in the table.
Provisioned throughput controls how much read and write capacity your table has.
Summary
Creating a table is the first step to store data in DynamoDB.
You must define a table name, primary key, and capacity settings.
Use the AWS CLI command 'aws dynamodb create-table' with proper options.