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

Provided by Rafal Wilinski
Last updated: October 23rd, 2026
DeleteItem removes one item identified by its full primary key. Deleting a key that does not exist succeeds without creating or changing another item.
This example uses Java 17+ and the software.amazon.awssdk:dynamodb SDK 2.x dependency. Configure an AWS Region and credentials through your usual AWS profile or runtime role. The Orders table has String keys pk and sk; adapt the table and keys to your schema.
import java.util.*; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.*; public class Example { static AttributeValue s(String value) { return AttributeValue.builder().s(value).build(); } static Map<String, AttributeValue> key(String order) { return Map.of("pk", s("CUSTOMER#123"), "sk", s(order)); } public static void main(String[] args) throws InterruptedException { try (DynamoDbClient ddb = DynamoDbClient.create()) { ddb.deleteItem(DeleteItemRequest.builder() .tableName("Orders").key(key("ORDER#001")).build()); } } }
For a table with a sort key, supplying only the partition key is insufficient. Use a query followed by individual deletes to remove an entire item collection.
Reference: AWS DeleteItem API. For related access patterns, see DynamoDB query examples.
Similar Code Examples
- Get All Items from DynamoDB Using Java
- Delete Expression in DynamoDB Using Java
- Get Item Request in DynamoDB Using Java
- Get Multiple Items in DynamoDB Using Java
- Query Local Secondary Index in DynamoDB Using Java
- Batch Read in DynamoDB Using Java
- Query Date Range in DynamoDB Using Java
- Batch Load Using DynamoDB Mapper
- Update Expression in DynamoDB Using Java
- Query Global Secondary Index in DynamoDB Using Java
- Query Index in DynamoDB Using Java
- Batch Insert in DynamoDB Using Java
- Conditional Update in DynamoDB Using Java
- Batch Update Using DynamoDB Mapper
- Delete All Items in DynamoDB Using Java
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase