Delete All Using DynamoDB Mapper (Guide w/ Code Examples)
![Rafal Wilinski](https://pbs.twimg.com/profile_images/1390706809548197895/SVCKpLNE_400x400.png)
Provided by Rafal Wilinski
There is no direct way to remove all items in a DynamoDB table. Therefore, you will have to scan the table and then execute a batch delete or iteratively delete items one by one.
However, you can use the method to delete all items in a table using the DynamoDB Mapper. It takes a list of objects to delete and deletes them in a single request.
DynamoDBMapper mapper = new DynamoDBMapper(client); // Load all items from the table List<Item> items = mapper.scan(Item.class, new DynamoDBScanExpression()); // Delete the items in a batch mapper.batchDelete(items);
Note that this will only delete the items in the table, not the table itself. If you want to delete the table and all its items, you can use the deleteTable
method of the AmazonDynamoDB
client.
DeleteTableRequest request = new DeleteTableRequest().withTableName("myTable"); client.deleteTable(request);
Remember that the deleteTable
method permanently deletes the table and all of its data.
Similar Code Examples
- Delete All Items in DynamoDB Using Java
- Conditional Update in DynamoDB Using Java
- Update Multiple Attributes in DynamoDB Using Java
- Update Expression in DynamoDB Using Java
- Update Attribute in DynamoDB Using Java
- Get in DynamoDB Using Java
- Insert in DynamoDB Using Java
- Delete in DynamoDB Using Java
- Query Date Range in DynamoDB Using Java
- Batch Save Using DynamoDB Mapper
- Query Index in DynamoDB Using Java
- Batch Read in DynamoDB Using Java
- Query Local Secondary Index in DynamoDB Using Java
- Batch Write Item in DynamoDB Using Java
- Batch Write Using DynamoDB Mapper
Better DynamoDB experience.
First 7 days are. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase