title: DB2 - Can I recreate a foreign key constraint in a table with data?
body: <p>I'm having the following problem with DB2:
  I need to change a column name (column "A"), but the thing is that column A has a PK constraint and a FK constraint. So I need to drop this constraints first, change the column name and then create the constraints again. But I remember a Professor told me once that you can't create a foreign key in a column which already has values. Is that true?</p>
  
  <p>This is my script:</p>
  
  <pre><code>ALTER TABLE TARGET_TABLE 
      DROP PRIMARY KEY PK_A CASCADE;
  
  ALTER TABLE TARGET_TABLE 
      RENAME COLUMN A TO B;
  
  alter table TARGET_TABLE 
  add CONSTRAINT PK_B PRIMARY KEY( B);
  
  alter table TARGET_TABLE add CONSTRAINT FK_B FOREIGN KEY( B) REFERENCES OTHER_TABLE(C);
  
  </code></pre>
  
  <p>Thanks in advance.</p>