Changing the primary key on existing DB2 Table

 

 
 
 
 
 
 
 
 
 
Changing the primary key on existing DB2 Table
 
 
How to change the primary key on an existing DB2 Table?
 
If you want to change the primary key of a table that already
exists then you can use the following ALTER query
 
ALTER TABLE Table_Name DROP PRIMARY KEY;
 
ALTER TABLE Table_Name ADD PRIMARY KEY (Column_One, Column_Two);
 
Where Table_Name is the name of the DB2 table for which you wish to 
change the primary key and Column_One and Column_two are the column 
names which will be used as Primary Key.
; ; ; ;