问题描述
我是Cosmos DB的新手,我注意到我们可以根据需要设置分区键,以便通过这样的代码有效地扩展:
I am new to Cosmos DB and I noticed that we can set the partition key based on needs to scale effectively through code like this:
DocumentCollection myCollection = new DocumentCollection();
myCollection.Id = "coll";
myCollection.PartitionKey.Paths.Add("/deviceId");
问题是我们可以在创建集合并指定分区键之后再更改分区键吗?我可能会发现分区键的选择稍后不合适.
Question is can we change the partition key later on after we created the collection and specified the partition key? As I may find out that the choice of partition key is not proper later.
推荐答案
不支持更改分区键(请参见例如 https://docs.microsoft.com/zh-cn/rest/api/cosmos-db/replace-a-collection ).您将需要创建一个新集合.
Changing the partition key is not supported (see e.g. https://docs.microsoft.com/en-us/rest/api/cosmos-db/replace-a-collection). You would need to create a new collection.
这篇关于在Azure Cosmos DB中,一旦我们决定一开始就可以稍后再更改分区键吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!