IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

alter the primar key


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabahar

New User


Joined: 25 Nov 2005
Posts: 6

PostPosted: Mon Jan 30, 2006 3:52 pm
Reply with quote

We need to add two new columns to an existing table. One of the new column has to be added to the composite primary key. The table already has a composite primary key. Can we alter the primary key and add the new column as a part of primary key.

Suggestios are welcome.
Regards,
Prabahar
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Jan 30, 2006 5:18 pm
Reply with quote

Quote:
Can we alter the primary key and add the new column as a part of primary key.


Better u can drop the key and again add the same.
Back to top
View user's profile Send private message
senthilssg

New User


Joined: 09 Dec 2005
Posts: 64
Location: USA

PostPosted: Tue Jan 31, 2006 11:39 am
Reply with quote

Hi ,


1. first drop the primary key of the table .
2. after that drop the index on that table .
3. create new index for the table as per the requirement .
4. now using alter table statement

ALTER TABLE SSGSEN.TRIAL_TABLE
ADD PRIMARY KEY (field_name);

uou can add the primary key to the table .


I hope this help you


Regards,
Senthil
Back to top
View user's profile Send private message
prabahar

New User


Joined: 25 Nov 2005
Posts: 6

PostPosted: Tue Jan 31, 2006 4:27 pm
Reply with quote

Thank you all for your timely help

Regards,
Prabahar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DROP & ALTER PARTITION-PBR DB2 0
No new posts Alter User LOGON Script Parameters CLIST & REXX 11
No new posts VSAM Alter Command - Cylinder Extent ... JCL & VSAM 3
No new posts OUTREC with ALter Command DFSORT/ICETOOL 1
No new posts Alter &DATENS field in HEADER1 DFSORT/ICETOOL 4
Search our Forums:

Back to Top