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

    Question

  • 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"

     

    Friday, April 27, 2012 6:27 AM

Answers

  • 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.

    • Marked as answer by shrimpy Friday, April 27, 2012 6:39 AM
    Friday, April 27, 2012 6:31 AM

All replies

  • 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.

    • Marked as answer by shrimpy Friday, April 27, 2012 6:39 AM
    Friday, April 27, 2012 6:31 AM
  • 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

    Friday, April 27, 2012 7:41 AM
  • 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.
    Friday, April 27, 2012 4:58 PM