Delete in DynamoDB Using Java (Guide w/ Code Examples)

Provided by Rafal Wilinski
To delete an item from a DynamoDB table in Java, you can use the deleteItem
method of the AmazonDynamoDB
client.
In the snippet defined below, YourTableName
is the name of the table you want to delete the item from, YourHashKeyValue
is the value of the hash key for the item you want to delete, and YourRangeKeyValue
is the value of the range key for the item you want to delete.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; import com.amazonaws.services.dynamodbv2.model.DeleteItemRequest; import com.amazonaws.services.dynamodbv2.model.DeleteItemResult; public class DynamoDBDeleteExample { public static void main(String[] args) { AmazonDynamoDB client = AmazonDynamoDBClientBuilder.defaultClient(); DeleteItemRequest request = new DeleteItemRequest() .withTableName("YourTableName") .withKey( new Key().withHashKeyElement(new AttributeValue("YourHashKeyValue")) .withRangeKeyElement(new AttributeValue("YourRangeKeyValue"))); DeleteItemResult result = client.deleteItem(request); System.out.println("Item deleted successfully!"); } }
Similar Code Examples
- Update Item in DynamoDB Using Java
- Get in DynamoDB Using Java
- Batch Insert in DynamoDB Using Java
- Delete All Using DynamoDB Mapper
- Batch Save Using DynamoDB Mapper
- Query Global Secondary Index in DynamoDB Using Java
- Conditional Update in DynamoDB Using Java
- Batch Write Item in DynamoDB Using Java
- Batch Put Item in DynamoDB Using Java
- Delete by Hashkey Using DynamoDB Mapper
- Remove with DynamoDB Mapper
- Insert in DynamoDB Using Java
- Query Date Range in DynamoDB Using Java
- Batch Delete Using DynamoDB Mapper
- Delete Multiple Items in DynamoDB Using Java
Dynobase is a Professional GUI Client for DynamoDB
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase