Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Creating a Table

Tables are the fundamental data structures in relational databases and in DynamoDB. A relational database management systems (RDBMS) requires you to define the table's schema when you create it. In contrast, DynamoDB tables are schemaless—other than the primary key, you do not need to define any attributes or data types at table creation time.


Use the CREATE TABLE statement to create a table, as shown in the following example.

CREATE TABLE Music ( Artist VARCHAR(20) NOT NULL, SongTitle VARCHAR(30) NOT NULL, AlbumTitle VARCHAR(25), Year INT, Price FLOAT, Genre VARCHAR(10), Tags TEXT, PRIMARY KEY(Artist, SongTitle) );

The primary key for this table consists of Artist and SongTitle.

You must define all of the table's columns and data types, and the table's primary key. (You can use the ALTER TABLE statement to change these definitions later, if necessary.)

Many SQL implementations let you define storage specifications for your table, as part of the CREATE TABLE statement. Unless you indicate otherwise, the table is created with default storage settings. In a production environment, a database administrator can help determine the optimal storage parameters.


Use the CreateTable action to create a table, specifying parameters as shown following:

{ TableName : "Music", KeySchema: [ { AttributeName: "Artist", KeyType: "HASH", //Partition key }, { AttributeName: "SongTitle", KeyType: "RANGE" //Sort key } ], AttributeDefinitions: [ { AttributeName: "Artist", AttributeType: "S" }, { AttributeName: "SongTitle", AttributeType: "S" } ], ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 } }

The primary key for this table consists of Artist (partition key) and SongTitle (sort key).

You must provide the following parameters to CreateTable:

  • TableName – Name of the table.

  • KeySchema – Attributes that are used for the primary key. For more information, see Tables, Items, and Attributes and Primary Key.

  • AttributeDefinitions – Data types for the key schema attributes.

  • ProvisionedThroughput – Number of reads and writes per second that you need for this table. DynamoDB reserves sufficient storage and system resources so that your throughput requirements are always met. You can use the UpdateTable action to change these later, if necessary. You do not need to specify a table's storage requirements because storage allocation is managed entirely by DynamoDB.


For code samples using CreateTable, see the Amazon DynamoDB Getting Started Guide.

On this page: