title: How to change values of foreign keys in postgresql?
body: <p>Let's say I have two tables: <code>Customer</code> and <code>City</code>. There are many <code>Customer</code>s that live in the same <code>City</code>. The cities have an <code>uid</code> that is primary key. The customers have a foreign key reference to their respective city via <code>Customer.city_uid</code>. </p>
  
  <p>I have to swap two <code>City.uid</code>s with one another for external reasons. But the customers should stay attached to their cities. Therefore it is necessary to swap the <code>Customer.city_uid</code>s as well. So I thought I first swap the <code>City.uid</code>s and then change the <code>Customer.city_uid</code>s accordingliy via an <code>UPDATE</code>-statement. Unfortunately, I can not do that since these <code>uids</code> are referenced from the <code>Customer</code>-table and PostgreSQL prevents me from doing that.</p>
  
  <p>Is there an easy way of swapping the two <code>City.uid</code>s with one another as well as the <code>Customer.city_uid</code>s?</p>