可以通过数据管道转储DynamoDb,也可以在DynamoDb中导入数据。导入进展顺利,但数据一直附加到DynamoDb中已存在的数据。
现在我找到了扫描DynamoDb并逐个或批量删除项目的工作示例。但无论如何,对于大量数据而言,它并不是一个好的变体。
也可以删除表格并创建它。但随着这种变体,索引将会丢失。
因此,最好的方法是通过Data Pipeline导入或以某种方式截断来覆盖DynamoDb数据。有可能吗?如果可以,怎么可能呢?
答案 0 :(得分:2)
DynamoDB中没有截断表功能,所以请考虑删除表&再次创建,
原因:DynamoDB根据ReadCapacityUnits
&您使用的WriteCapacityUnits
。如果您使用BatchWriteItem
功能删除所有项目,则会使用WriteCapacityUnits
。因此,要保存这些WriteCapacityUnits
以删除项目,最好是截断表格&重新创造它。
删除&的步骤按如下方式创建DynamoDB表:
aws dynamodb delete-table --table-name *tableName*
Delete Table via AmazonDynamoDB API:
样品申请
POST / HTTP/1.1 Host: dynamodb.<region>.<domain>; Accept-Encoding: identity Content-Length: <PayloadSizeBytes> User-Agent: <UserAgentString> Content-Type: application/x-amz-json-1.0 Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature> X-Amz-Date: <Date> X-Amz-Target: DynamoDB_20120810.DeleteTable { "TableName": "Reply" }
Creating DynamoDB Table via AmazonDynamoDB API:
POST / HTTP/1.1 Host: dynamodb.<region>.<domain>; Accept-Encoding: identity Content-Length: <PayloadSizeBytes> User-Agent: <UserAgentString> Content-Type: application/x-amz-json-1.0 Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature> X-Amz-Date: <Date> X-Amz-Target: DynamoDB_20120810.CreateTable { "AttributeDefinitions": [ { "AttributeName": "ForumName", "AttributeType": "S" }, { "AttributeName": "Subject", "AttributeType": "S" }, { "AttributeName": "LastPostDateTime", "AttributeType": "S" } ], "TableName": "Thread", "KeySchema": [ { "AttributeName": "ForumName", "KeyType": "HASH" }, { "AttributeName": "Subject", "KeyType": "RANGE" } ], "LocalSecondaryIndexes": [ { "IndexName": "LastPostIndex", "KeySchema": [ { "AttributeName": "ForumName", "KeyType": "HASH" }, { "AttributeName": "LastPostDateTime", "KeyType": "RANGE" } ], "Projection": { "ProjectionType": "KEYS_ONLY" } } ], "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5 } }
摘要:删除表&amp;再次创建将是最佳解决方案。