Adding Primary Key on exisitng DB2 Table

 

 
 
 
 
 
 
 
 
 
 
 
Adding Primary Key on exisitng DB2 Table
 
 
How to defina a primary key on an existing DB2 table?
 
 
To define a primary key on a table which exists you will need
to use the ALTER command, the following example query will give 
you the intended result
 
 
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.
; ; ; ;