title: restart so that nextval is the next unused id
body: <p>I've got a script which copies table data from one DB to another, however the ID column is backed by a sequence so when a new record is inserted into the destination table the <code>nextval(seq)</code> is returning the wrong value.</p>
  
  <p>I need to update the sequence so that it starts at the next available ID.</p>
  
  <p>I want to do something like:</p>
  
  <pre><code>ALTER SEQUENCE seq_id RESTART WITH
      (SELECT MAX(id) FROM tbl);
  </code></pre>
  
  <p>The above produces a syntax error however.</p>
  
  <p>Can anyone suggest an alternative approach?</p>