Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all the Existing tables in DynamoDb?

I wants to delete all the existing tables in my database in DynamoDb?

Is there any way to do it?

like image 514
Bhavik Joshi Avatar asked Mar 25 '15 11:03

Bhavik Joshi


2 Answers

You can use aws cli to delete all tables, may be except one table.

aws dynamodb list-tables --profile your_profile | jq .'TableNames[]' -r | grep -v table_you_dont_want_to_delete | xargs -ITABLE -n 1 aws dynamodb delete-table --table-name TABLE --profile your_profile
like image 109
halil Avatar answered Oct 06 '22 22:10

halil


You can delete table using below code.

var params = {
    TableName: 'table-name',
};
dynamodb.deleteTable(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});
like image 40
sid Avatar answered Oct 06 '22 21:10

sid