Search code examples
azuret-sqlazure-storageazure-storage-emulator

How to delete table data from Azure Storage Explorer?


I have a storage account and Tables in storage account .I couldnt find any good article which would point me on how to delete data from Table in Azure Storage Account. It also doesnt seem like a straight forward sql deletion query to do the task (When i tried it takes forever to execute). when i can have some query to retrive data from azure storage table why is there no proper documentation to delete the data?.However deleting row by seleting the row and using delete button worked but its not ideal thing to do. I have used the following query to retrive data

PartitionKey eq '123' and Type eq 'SomeText'

I want to delete data too.Query what i am trying to achieve would be something similar like ,

Delete from MyTable where PartitionKey eq '123' and Type eq 'SomeText'

But the above query takes forever and it fails execution at end. As i am new to azure any help to point me in right direction is highly appreciated.(


Solution

  • This query won't work:

    Delete from MyTable where PartitionKey eq '123' and Type eq 'SomeText'
    

    as Azure Tables don't support deleting this way.

    What you would need to do is fetch the entities using PartitionKey eq '123' and Type eq 'SomeText' and then delete the fetched entities either one by one or in an entity batch transaction.

    To speed up the operation, you can:

    • Use query projection and only return PartitionKey and RowKey as only these two attributes are required for deletion.
    • Use entity batch transaction and delete up to 100 entities in a single request. Please note that this is only applicable when you're deleting entities programmatically. Within Storage Explorer, you will need to select the entities and then delete them.