title: Atomic [move to another table, then delete original data]
body: <p>I have a <strong>Data</strong> table and an <strong>Archive</strong> table.</p>
  
  <p>A webapp pours data into the <strong>Data</strong> table, and a cron job pulls the data out every hour and archives it in the <strong>Archive</strong> table (this keeps the <strong>Data</strong> table small and quick to work with).</p>
  
  <p>As I see it there are two psudo-SQL queries to run:</p>
  
  <pre><code>INSERT Archive SELECT * FROM Data;
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>DELETE FROM Data;
  </code></pre>
  
  <p>However, I only want to delete the data that was successfully copied, if the copy fails I want it to be left in a consistent state, with the data neither half-moved, nor deleted.</p>
  
  <p>What's the right way to do this?</p>