title: How to copy structure and contents of a table, but with separate sequence?
body: <p>I'm trying to setup temporary tables for unit-testing purposes. So far I managed to create a temporary table which copies the structure of an existing table:</p>
  
  <pre><code>CREATE TEMP TABLE t_mytable (LIKE mytable INCLUDING DEFAULTS);
  </code></pre>
  
  <p>But this lacks the data from the original table. I can copy the data into the temporary table by using a <code>CREATE TABLE AS</code> statement instead:</p>
  
  <pre><code>CREATE TEMP TABLE t_mytable AS SELECT * FROM mytable;
  </code></pre>
  
  <p>But then the structure of <code>t_mytable</code> will not be identical, e.g. column sizes and default values are different. Is there a single statement which copies everything?</p>
  
  <p>Another problem with the first query using <code>LIKE</code> is that the key column still references the <code>SEQUENCE</code> of the original table, and thus increments it on insertion. Is there an easy way to create the new table with its own sequence, or will I have to set up a new sequence by hand?</p>