Adding new column and altering Primary Key of DB2 Table

1 post / 0 new
Anonymous
Adding new column and altering Primary Key of DB2 Table

 

 

 

 

 

I had a requirement where I was supposed to add a new column 
to a DB2 table and add this column to the Primary Key contraint.
 
This table already had three columns part of Primary key.
 
As per my solution I decided to 
 
  • Alter the table to add new column
 
  • Drop the existing Primary Key contraint
 
  • and Add a new primary key contraint which has all the four columns
 
Now this query did fail in the third step, i.e while
creating the primary key constraint and gave me some sql error, 
indicating that there does not exist a unique index on the table.
 
Since the column has already got added, I do not want to drop it and 
start all over again, Is it possible to somehow fix the problem 
without restoring and restarting from scratch.
"; ; ; ;
Sponsored Listing