Basic Operations for Tables

Creating a Table

Use the CreateTable operation to create a table. You must provide the
following information:

Table name. The name must conform to the
DynamoDB naming rules, and must be unique for the current AWS account and
region. For example, you could create a People table in
US East (N. Virginia) and another People table in
EU (Ireland) - however, these two tables would be entirely different
from each other. For more information, see Naming Rules and Data Types.

Primary key. The primary key can consist of
one attribute (partition key) or two attributes (partition key and sort
key). You need to provide the attribute names, data types, and the role of
each attribute: HASH (for a partition key) and
RANGE (for a sort key). For more information, see Primary Key.

The following AWS CLI example shows how to create a table
(Music). The primary key consists of
Artist (partition key) and
SongTitle (sort key), each of which has a data type of
String. The maximum throughput for this table is 10 read capacity units and 5
write capacity units.

The TableStatus element indicates the current state of the table
(CREATING). It might take a while to create the table, depending on
the values you specify for ReadCapacityUnits and
WriteCapacityUnits. Larger values for these will require DynamoDB to
allocate more resources for the table.

Describing a Table

To view details about a table, use the DescribeTable operation. You
must provide the table name. The output from DescribeTable is in the
same format as that from CreateTable; it includes the timestamp when
the table was created, its key schema, its provisioned throughput settings, its
estimated size, and any secondary indexes that are present.

Example

aws dynamodb describe-table --table-name Music

The table is ready for use when the TableStatus has changed from
CREATING to ACTIVE.

Note

If you issue a DescribeTable request immediately after a
CreateTable request, DynamoDB might return an error
(ResourceNotFoundException). This is because
DescribeTable uses an eventually consistent query, and the
metadata for your table might not be available at that moment. Wait for a few
seconds, and then try the DescribeTable request again.

For billing purposes, your DynamoDB storage costs include a per-item overhead of
100 bytes. (For more information, go to DynamoDB Pricing). This extra
100 bytes per item is not used in capacity unit calculations or by the
DescribeTable operation.

When you issue an UpdateTable request, the status of the table
changes from AVAILABLE to UPDATING. The table remains
fully available for use while it is UPDATING. When this process is
completed, the table status changes from UPDATING to
AVAILABLE.

Deleting a Table

You can remove an unused table with the DeleteTable operation. Note
that deleting a table is an unrecoverable operation.

This AWS CLI example shows how to delete a table:

aws dynamodb delete-table --table-name Music

When you issue a DeleteTable request, the table's status changes from
ACTIVE to DELETING. It might take a while to delete
the table, depending on the resources it uses (such as the data stored in the table,
and any streams or indexes on the table).

When the DeleteTable operation concludes, the table no longer exists
in DynamoDB.

Listing Table Names

The ListTables operation returns the names of the DynamoDB tables for
the current AWS account and region.

Example

aws dynamodb list-tables

Describing Provisioned
Throughput Limits

The DescribeLimits operation returns the current read and write
capacity limits for the current AWS account and region.

Example

aws dynamodb describe-limits

The output shows the upper limits of read and write capacity units for the
current AWS account and region.