Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop column in Dynamo DB table

I've been looking through the AWS Dynamo DB documentation and the Amazon Dynamo interface and it seems like there's no way to remove a column from a table, outside of deleting the entire table with it's contents and starting over, is that true?

If so, why would Amazon not support this?

like image 328
yekta Avatar asked Mar 10 '15 13:03

yekta


People also ask

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 do I remove items from DynamoDB?

With the DynamoDB API, you use the DeleteItem action to delete data from a table, one item at a time. You must specify the item's primary key values. In addition to DeleteItem , Amazon DynamoDB supports a BatchWriteItem action for deleting multiple items at the same time.

How do I edit items in DynamoDB table?

To update an existing item in an Amazon DynamoDB table, you use the UpdateItem operation. You must provide the key of the item that you want to update. You must also provide an update expression, indicating the attributes that you want to modify and the values that you want to assign to them.


2 Answers

Try removing all data from that column, it will automatically remove that column.

like image 55
Parveen Verma Avatar answered Sep 27 '22 03:09

Parveen Verma


Using document client with javascript, we can do this:

const paramsUpdate = {
       TableName: tableName,
       Key: { HashKey: 'hashKey' },
       UpdateExpression: 'remove #c ',
       ExpressionAttributeNames: { '#c': 'columnName' }
};
documentClient.update(paramsUpdate, (errUpdate) => {
       if (errUpdate) log.error(errUpdate);
});

In here we set UpdateExpression with remove sentence

like image 23
nitya wijayanti Avatar answered Sep 23 '22 03:09

nitya wijayanti