How to create a DynamoDB table in AWS

Key takeaways:

  • DynamoDB is a fully managed NoSQL database service provided by AWS, designed for high scalability, flexibility, and reliability.

  • There are various methods to create a DynamoDB table, including the AWS Management Console, AWS CLI, AWS SDKs, CloudFormation, and the Serverless Application Model.

  • Using AWS CLI to create a DynamoDB table offers a powerful way to automate table management through scripting, which is beneficial for developers looking to integrate DynamoDB operations into their workflows.

DynamoDB is a fully managed NoSQL database offered by Amazon Web Services (AWS). It is highly scalable, flexible, and reliable. It is designed to provide reliable performance for applications that store and retrieve large amounts of data.

DynamoDB features

DynamoDB is a document database that stores data as key-value pairs or JSON-like documents. It is optimized for performance and can handle millions of requests per second.

It also provides the following:

  • Automatic scaling feature

  • Backup and restore feature

  • Global replication feature

  • Enables low-latency access to data from anywhere in the world.

Create a table

There are many ways through which we can create a table in DynamoDB:

In this Answer, we will use AWS CLI to create a table in AWS DynamoDB. First of all, we will install and configure the AWS CLI on our local machine by using the following command :

aws configure

You can check out the AWS official documentationhttps://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html if you need more help regarding AWS configuration.

Now open the terminal, copy and paste the following command to create a new DynamoDB table:

aws dynamodb create-table \
--table-name MyTable \
--attribute-definitions \
AttributeName=ID,AttributeType=S \
AttributeName=Timestamp,AttributeType=N \
--key-schema \
AttributeName=ID,KeyType=HASH \
AttributeName=Timestamp,KeyType=RANGE \
--provisioned-throughput \
ReadCapacityUnits=5,WriteCapacityUnits=5 \

In the above query::

  • We created a table named “MyTable” with two attributes, ID and Timestamp.

  • The ID attribute is of type string (S) and is the hash key.

  • The Timestamp attribute is of type number (N) and is the range key.

  • The provisioned throughput is set to 5 read capacity units and 5 write capacity units.

We can customize this command to fit our specific use case by changing the table name, attributes, key schema, and provisioned throughput. We can also specify additional parameters, such as the table’s global secondary indexes, local secondary indexes, and tags.

Verification

We can check the status of the created table by using the following command.

aws dynamodb describe-table --table-name MyTable --region us-east-1

Once the table is created and active, we can add data using the AWS CLI or other AWS SDKs and tools.

Copy and paste the create table command into the below terminal, and your table will be created in DynamoDB.

Terminal 1
Terminal
Loading...

That’s it! You can easily create a DynamoDB table using the AWS CLI with these steps.

Conclusion

In conclusion, creating a DynamoDB table is a fundamental skill for anyone working with AWS services, particularly for applications requiring robust data storage solutions. This Answer outlines the critical steps and considerations for setting up a DynamoDB table using AWS CLI, highlighting its flexibility and powerful features. By mastering these concepts, you can effectively harness the capabilities of DynamoDB to build scalable and reliable applications that can handle vast amounts of data efficiently. Whether you are developing a new application or integrating with existing systems, understanding DynamoDB’s structure, features, and management techniques will enhance your proficiency in cloud-based data solutions.

Frequently asked questions

Haven’t found what you were looking for? Contact Us


Does DynamoDB have tables?

Yes, DynamoDB organizes data into tables.


Can we create DynamoDB table without sort key?

Yes, we can create a DynamoDB table with just a partition key, omitting the sort key.


How many tables can be created in DynamoDB?

We can create up to 256 tables per AWS account per region by default, but this limit can be increased upon request.


Free Resources

Copyright ©2025 Educative, Inc. All rights reserved