dynobase-icon
Dynobase

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

Rafal Wilinski

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, YourHashKeyValueis 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!"); } }

Login to the AWS Console less. Use Dynobase.

First 7 days are. No credit card needed.

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
/
Affiliates & Influencers
© 2024 Dynobase
+
Tired of AWS Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.