Search code examples
amazon-web-servicesamazon-dynamodbdynamodb-queries

Is it possible to insert items using secondary index of dynamoDb aws?


Can we insert an item using the global secondary index or local secondary index in dynamoDB? Because I had a table in which two items having the same partition key and sort key when I used the mapper.save() function, it usually update the current item, I want it to be separate i.e., I want two items in the table. If I am able to insert the item using secondary index than my problem will be solved.


Solution

  • No, you can only update the base table. And in the base table an item’s identity is defined by its primary key (combination of partition key and sort key). You cannot have two items with the same primary key.