是否可以在创建现有 DynamoDB 表后添加全局二级索引?我将 Python 3.x 与 Boto3 一起使用,但无法找到在创建表后将它们添加到表中的任何示例。
一般来说,是的,可以添加全局二级索引(GSI
) 创建表后。
然而,更改可能需要很长时间才能生效,因为构建GSI
需要进行表扫描。
如果是boto3
, 看一下的文档update_table http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.update_table
例如,你尝试这样的事情:
response = client.update_table(
TableName = 'YourTableName',
# ...snip...
GlobalSecondaryIndexUpdates=[
{
'Create': {
'IndexName': 'YourGSIName',
'KeySchema': [
{
'AttributeName': 'YourGSIFieldName',
'KeyType': 'HASH'
}
],
'Projection': {
'ProjectionType': 'ALL'
},
'ProvisionedThroughput': {
'ReadCapacityUnits': 1,
'WriteCapacityUnits': 1
}
}
}
],
# ...snip...
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)