Kann mir jemand wissen, ob UpdateTableSpec nur KeySchema-Attribute aktualisieren kann und gibt es eine Möglichkeit, eine Tabelle mit Nicht-Schlüsselschema-Attribute zu aktualisieren/ändern? Mein Szenario ist: Ich habe eine Tabelle mit einem zusammengesetzten Schlüssel erstellt, der aus einem primären Schlüssel (#id-Attribut) und einem Bereichsschlüssel (#Name-Attribut) besteht. Jetzt möchte ich ein drittes Attribut, Gender, hinzufügen, das nicht Teil des Schlüsselschemas ist. Ist es möglich ?UpdateTableSpec auf DynamoDB-Tabelle funktioniert nicht
ich meine DynamoDB Tabelle an Aktualisierung des folgenden Code verwenden, aber es ist nicht das Geschlecht Attribut hinzufügen, obwohl es erfolgreich das bereitgestellte Attribut aktualisiert:
static void updateTable() {
System.out.println("Updating the table with new attributes ...");
Table table = dynamoDB.getTable(tableName);
UpdateTableSpec updateTableSpec = new UpdateTableSpec();
List<AttributeDefinition> attributeDefinitionList = updateTableSpec.getAttributeDefinitions();
if (null == attributeDefinitionList) {
attributeDefinitionList = new ArrayList<AttributeDefinition>();
}
attributeDefinitionList.add(new AttributeDefinition()
.withAttributeName("Gender")
.withAttributeType("S"));
updateTableSpec.withAttributeDefinitions(attributeDefinitionList)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(6L)
.withWriteCapacityUnits(7L));;
table.updateTable(updateTableSpec);
try {
table.waitForActive();
System.out.println("Table updated succesfully");
} catch (final Exception ex) {
System.out.println("Exception occurred while updating the table");
}
}