Note that there are some explanatory texts on larger screens.

plurals
  1. POAzure Tables delete and create table fails
    primarykey
    data
    text
    <p>My problem is that from time to time I want to delete the <strong>contents</strong> of an Azure table from Java. The table has millions of rows so it didn't seem like a good method to delete all entities one by one (because of the many REST API calls).</p> <p>I tried to delete and then create the table again, but my code fails.</p> <pre><code>getTableClient().deleteTableIfExists("tablename"); getTableClient().createTableIfNotExists("tablename"); </code></pre> <p>Here is my stacktrace:</p> <pre><code>com.microsoft.windowsazure.services.table.client.TableServiceException: Conflict at com.microsoft.windowsazure.services.table.client.TableServiceException.generateTableServiceException(TableServiceException.java:57) at com.microsoft.windowsazure.services.table.client.TableOperation$2.execute(TableOperation.java:339) at com.microsoft.windowsazure.services.table.client.TableOperation$2.execute(TableOperation.java:322) at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.java:110) at com.microsoft.windowsazure.services.table.client.TableOperation.performInsert(TableOperation.java:374) at com.microsoft.windowsazure.services.table.client.TableOperation.execute(TableOperation.java:551) at com.microsoft.windowsazure.services.table.client.CloudTableClient.execute(CloudTableClient.java:638) at com.microsoft.windowsazure.services.table.client.CloudTableClient.createTable(CloudTableClient.java:173) at com.microsoft.windowsazure.services.table.client.CloudTableClient.createTableIfNotExists(CloudTableClient.java:251) at com.microsoft.windowsazure.services.table.client.CloudTableClient.createTableIfNotExists(CloudTableClient.java:197) </code></pre> <p>Do I have to sleep for a while between to two calls? I would rather not have too long wait here because I want to make this operation as short as possible so other threads can write again in the table.</p> <p>Or is there a safe way to do this?</p> <hr> <p><strong>Edit</strong></p> <p>Yes, I am looking for an equivalent of the SQL statement: <code>DELETE FROM tablename;</code> in Azure Tables with as few REST API calls as possible.</p> <p>My current best shot is:</p> <pre><code>getTableClient().deleteTableIfExists("tablename"); // TODO: solve problem with new creation! boolean success = false; while (!success) { try { success = getTableClient().createTableIfNotExists("tablename"); } catch (StorageException e) { System.err.println("Log table recreation failed retrying in 5 sec"); try { Thread.sleep(5000); } catch (InterruptedException ex) {} } </code></pre> <p>I am looking for a better and safer solution then this!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload