Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add primary sort key to an already existing table in AWS dynamo db?

I have a pre-existing dynamo db table to which i want to add a primary sort key. All the items in the table contain the key which i want to delegate as the primary sort key.

like image 262
Parth Verma Avatar asked Sep 27 '17 13:09

Parth Verma


People also ask

Can you add a sort key to an existing DynamoDB table?

DynamoDB doesn't allow to add Sort key for the existing table. It allows the following once the table is created. Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

Can we update the sort key in DynamoDB?

Can we update the sort key in DynamoDB? No, you can not update the sort key after the table is provisioned. However, you can create a new table and put the existing data in the newly created table, and delete the old table.

How do I add a column to an existing table in DynamoDB?

DynamoDB does not require schema definition, and so there is no such thing as a "column". You can just add a new item with a new attribute.

Can DynamoDB have 2 primary keys?

DynamoDB supports two types of primary keys: Partition key: A simple primary key, composed of one attribute known as the partition key.


1 Answers

DynamoDB doesn't allow to add Sort key for the existing table.

It allows the following once the table is created.

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

Solution:-

Please create a new table with redefined key attributes and copy the data from old table to new table.

like image 66
notionquest Avatar answered Sep 26 '22 02:09

notionquest