codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
☁️

AWS Cloud

39 / 60 topics
38Introduction to Amazon DynamoDB39Creating a DynamoDB Table40Querying Data in DynamoDB
Tutorials/AWS Cloud/Creating a DynamoDB Table
☁️AWS Cloud

Creating a DynamoDB Table

Updated 2026-05-15
10 min read

Creating a DynamoDB Table

Introduction

Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. In this tutorial, we will guide you through the process of creating and configuring a DynamoDB table using the AWS Management Console and AWS CLI.

Concept

DynamoDB tables consist of items, which are composed of attributes. Each attribute has a name and a value. DynamoDB supports various data types for these attributes, including strings, numbers, binary data, sets, lists, and maps. Tables in DynamoDB can be configured with different settings such as read/write capacity modes, indexes, and encryption.

Examples

Creating a DynamoDB Table Using the AWS Management Console

  1. Log in to the AWS Management Console:

    • Open your web browser and navigate to the AWS Management Console.
    • Log in with your AWS credentials.
  2. Navigate to DynamoDB:

    • In the AWS Management Console, find and click on "DynamoDB" under the "Database" services section.
  3. Create a New Table:

    • Click on the "Create table" button.
    • Enter a name for your table, such as MyFirstTable.
    • Choose the partition key (primary key) attribute name and type. For example, you can use id as the attribute name and set its type to String.
  4. Configure Additional Settings:

    • You can configure additional settings such as sort keys, read/write capacity modes, and indexes if needed.
    • For simplicity, we will stick with the default settings for this tutorial.
  5. Review and Create:

    • Review your table configuration and click on "Create" to create the table.

Creating a DynamoDB Table Using the AWS CLI

  1. Install AWS CLI:

    • If you haven't already installed the AWS CLI, you can download it from the AWS CLI installation page.
  2. Configure AWS CLI:

    • Run the following command to configure your AWS credentials:
      Terminal
      $ aws configure
    • Enter your AWS Access Key ID, Secret Access Key, region, and output format when prompted.
  3. Create a DynamoDB Table:

    • Use the aws dynamodb create-table command to create a new table. Here's an example command:
      Bash
      1aws dynamodb create-table --table-name MyFirstTable --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
    • This command creates a table named MyFirstTable with a single partition key (id) of type String. It also sets the read and write capacity units to 5.
  4. Verify Table Creation:

    • You can verify that your table has been created by listing all tables in DynamoDB:
      Terminal
      $ aws dynamodb list-tables
    • The output should include MyFirstTable in the list of tables.

Example: Inserting an Item into the Table

  1. Insert an Item Using AWS CLI:

    • Use the aws dynamodb put-item command to insert an item into your table. Here's an example command:
      Bash
      1aws dynamodb put-item --table-name MyFirstTable --item '{
      2 "id": {"S": "1"},
      3 "name": {"S": "John Doe"},
      4 "age": {"N": "30"}
      5}'
    • This command inserts an item with id as 1, name as John Doe, and age as 30.
  2. Retrieve the Item:

    • You can retrieve the inserted item using the aws dynamodb get-item command:
      Bash
      1aws dynamodb get-item --table-name MyFirstTable --key '{
      2 "id": {"S": "1"}
      3}'
    • The output should display the item you inserted.

What's Next?

In this tutorial, we learned how to create and configure a DynamoDB table using both the AWS Management Console and AWS CLI. In the next section, we will explore how to query data in DynamoDB, allowing us to retrieve and manipulate the data stored in our tables.

Feel free to experiment with different configurations and settings to suit your application's needs. DynamoDB offers powerful features for managing large-scale applications with high availability and performance.


PreviousIntroduction to Amazon DynamoDBNext Querying Data in DynamoDB

Recommended Gear

Introduction to Amazon DynamoDBQuerying Data in DynamoDB