none
can we update partition key or row key in azure table storage

    คำถาม

  • when using azure table storage,
    after created an entry inside a table,
    can i update the parititon key or row key?

    e.g if i have a table

        -PartitionKey    : "parition1"
        -RowKey          : "row1
        -Col1            : "abc"
        -Col2            : "bcd"

    can i update the partition key?
    change the above to

        -PartitionKey    : "parition2"
        -RowKey          : "row1
        -Col1            : "abc"
        -Col2            : "bcd"

     

    27 เมษายน 2555 6:27

คำตอบ

  • No. The combination of partition key and row key is the identity of the entity, so you have to delete the old entity and create a new one.

    If the two entities are in the same partition key ("changing the row key"), you can do the delete and the insert atomically as part of an "entity group transaction." If the two entities have different partition keys ("changing the partition key"), there's no way to do this atomically.

    • ทำเครื่องหมายเป็นคำตอบโดย shrimpy 27 เมษายน 2555 6:39
    27 เมษายน 2555 6:31

ตอบทั้งหมด

  • No. The combination of partition key and row key is the identity of the entity, so you have to delete the old entity and create a new one.

    If the two entities are in the same partition key ("changing the row key"), you can do the delete and the insert atomically as part of an "entity group transaction." If the two entities have different partition keys ("changing the partition key"), there's no way to do this atomically.

    • ทำเครื่องหมายเป็นคำตอบโดย shrimpy 27 เมษายน 2555 6:39
    27 เมษายน 2555 6:31
  • No. The combination of partition key and row key is the identity of the entity, so you have to delete the old entity and create a new one.

    If the two entities are in the same partition key ("changing the row key"), you can do the delete and the insert atomically as part of an "entity group transaction." If the two entities have different partition keys ("changing the partition key"), there's no way to do this atomically.

    I would like to make one correction: Based on the documentation for Performing Entity Group Transactions (http://msdn.microsoft.com/en-us/library/windowsazure/dd894038.aspx), I don't think you can delete an entity and create it in the same transaction as an entity can appear only once in a transaction (Section: Requirements for Entity Group Transactions). My guess is that you would need to perform two separate transactions: one to delete it and other one to create it.

    Hope this helps.

    Thanks

    Gaurav

    27 เมษายน 2555 7:41
  • Ah, but they're not the same entity. They have different row keys (which means they're different entities), so what's appearing in the transaction is a delete for one entity and then an insert for a different entity.
    27 เมษายน 2555 16:58