title: PostgreSQL: Update primary key, avoid conflict
body: <p>I want to update the primary key in several rows of a table. If all rows were updated, the key would be unique again, but the update of the first row results in a temporary conflict with the key of the second row. Is there an elegant way to solve this?</p>
  
  <p>Example:</p>
  
  <pre><code>create table erichtest ( i integer, v varchar(200) );
  alter table erichtest add constraint pk_erichtest primary key(i);
  insert into erichtest values(1, 'Eins');
  insert into erichtest values(2, 'Zwei');
  update erichtest set i=i+1;
  </code></pre>
  
  <blockquote>
    <p>ERROR:  duplicate key value violates unique constraint "pk_erichtest"</p>
  </blockquote>