A developer needs to rename the primary key value of an existing item in an Amazon DynamoDB table because the business identifier has changed. Which approach will accomplish this requirement while following DynamoDB best practices?
Create a global secondary index and update the key through the index, which automatically propagates the change to the base table.
Delete the existing item and recreate it with a PutItem request that includes the new primary key value.
Use UpdateItem with an UpdateExpression to set the new value for the key attribute.
Run an ALTER TABLE command in the AWS Management Console to rename the key.
DynamoDB does not permit changes to an item's primary key with UpdateItem or any other in-place operation. The correct way to 'rename' a key is to delete the original item (DeleteItem) and then recreate it (PutItem or BatchWriteItem) with the new key value. Primary key immutability applies regardless of whether the table uses a simple partition key or a composite partition-and-sort key. Local and global secondary indexes also cannot be used to alter the underlying key of an item; they merely provide additional query paths. SQL-style ALTER TABLE statements are not supported in DynamoDB.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
Why can't the primary key of an item in DynamoDB be updated directly?
Open an interactive chat with Bash
What is the difference between a Partition Key and a Sort Key in DynamoDB?
Open an interactive chat with Bash
What are global and local secondary indexes in DynamoDB, and how are they different?
Open an interactive chat with Bash
AWS Cloud Practitioner CLF-C02
Cloud Technology and Services
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .