Amazon dynamodb 使用aws cli向DynamoDB中的现有表添加全局辅助索引
我似乎找不到如何使用aws cli在DynamoDB中向现有表添加全局二级索引的示例。Amazon dynamodb 使用aws cli向DynamoDB中的现有表添加全局辅助索引,amazon-dynamodb,aws-cli,Amazon Dynamodb,Aws Cli,我似乎找不到如何使用aws cli在DynamoDB中向现有表添加全局二级索引的示例。 这就是我所知道的,迄今为止从 任何指针都将不胜感激这是更新表 示例: aws dynamodb update-table --table-name <tableName> --global-secondary-index-updates file://gsi-command.json 更新表文档的选项部分中有一小段提到了所需的属性,它要求属性定义包括新索引的关键元素。只需将该选项添加到@conc
这就是我所知道的,迄今为止从
任何指针都将不胜感激这是
更新表
示例:
aws dynamodb update-table --table-name <tableName> --global-secondary-index-updates file://gsi-command.json
更新表文档的选项部分中有一小段提到了所需的属性,它要求属性定义包括新索引的关键元素。只需将该选项添加到@conceptquest提供的示例末尾就可以了
aws dynamodb update-table --table-name <tableName> --global-secondary-index-updates file://gsi-command.json --attribute-definitions AttributeName=<attributeName>, AttributeType=<attributeType>
aws dynamodb更新表--表名--全局二级索引更新file://gsi-command.json --属性定义AttributeName=,AttributeType=
在现有表中创建全局二级索引。
使用此CLI命令和JSON文件进行更新
aws dynamodb update-table --table-name sample--cli-input-json file://gsi-update.json --endpoint-url http://localhost:8000
以JSON格式保存参数
{
"AttributeDefinitions":[
{
"AttributeName":"String",
"AttributeType":"S"
},
{
"AttributeName":"String",
"AttributeType":"S"
}
],
"GlobalSecondaryIndexUpdates":[
{
"Create":{
"IndexName":"index-name",
"KeySchema":[
{
"AttributeName":"String",
"KeyType":"HASH"
},
{
"AttributeName":"String",
"KeyType":"RANGE"
}
],
"Projection":{
"ProjectionType":"ALL"
},
"ProvisionedThroughput":{
"ReadCapacityUnits":5,
"WriteCapacityUnits":5
}
}
}
]
}
{
"AttributeDefinitions":[
{
"AttributeName":"String",
"AttributeType":"S"
},
{
"AttributeName":"String",
"AttributeType":"S"
}
],
"GlobalSecondaryIndexUpdates":[
{
"Create":{
"IndexName":"index-name",
"KeySchema":[
{
"AttributeName":"String",
"KeyType":"HASH"
},
{
"AttributeName":"String",
"KeyType":"RANGE"
}
],
"Projection":{
"ProjectionType":"ALL"
},
"ProvisionedThroughput":{
"ReadCapacityUnits":5,
"WriteCapacityUnits":5
}
}
}
]
}