Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deletion from amazon dynamodb

Tags:

Is there any efficient way to delete all the items from a amazon dynamodb tabe at once.I have gone through the aws docs but there it's shown deletion of a single item.

like image 965
rampuriyaaa Avatar asked Apr 12 '13 05:04

rampuriyaaa


People also ask

How do I delete multiple rows in DynamoDB?

To delete a single item, use DeleteItem. To delete multiple items, use BatchWriteItem. Despite the naming of BatchWriteItem , it can be used to put multiple items or to delete multiple items, and you can target one or more DynamoDB tables in the same API call.

How do I delete a column in DynamoDB?

Navigate to the console. In the navigation pane on the left side, select Tables. Then select the table name, and the Items tab. Choose the items desired for deletion, and select Actions | Delete.

How long does it take to delete a DynamoDB table?

Dynamo tables tend to be slow on deletes - around 5 minutes is quite normal. The problem is often people want to delete the table and re-create it as cleanup, but this will inject a downtime. Renaming also isn't fast - so deleting the items (and pay for that) is an option or to use TTLs.


2 Answers

Do the following steps:

  1. Make delete table request
  2. In the response you will get the TableDescription
  3. Using TableDescription create the table again.

For step 1 and 2 click here

for step 3 click here

That's what I do in my application.

like image 170
Ihtsham Minhas Avatar answered Nov 15 '22 05:11

Ihtsham Minhas


DynamoDBMapper will do the job in few lines :

AWSCredentials credentials = new PropertiesCredentials(credentialFile);
client = new AmazonDynamoDBClient(credentials);
DynamoDBMapper mapper = new DynamoDBMapper(this.client);
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
PaginatedScanList<LogData> result = mapper.scan(LogData.class,  scanExpression);
for (LogData data : result) {
    mapper.delete(data);
}
like image 32
Nicolas M Avatar answered Nov 15 '22 04:11

Nicolas M