MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Add new Column to the composite PrimaryKey

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Ogv
Beginner


Joined: 23 Dec 2002
Posts: 10
Topics: 5
Location: NJ, USA

PostPosted: Wed Feb 19, 2003 6:12 pm    Post subject: Add new Column to the composite PrimaryKey Reply with quote

In our shop we need to add one more column to the existing table and it will be a part of the existing primary key (composite key already).

Can we drop the index and primary key, create index for the whole composite and then create the primaray key for this composite key ?

Or should we drop the table and insert the new col next to the current composite key and then load the old data?

Which option will be a good option performance-wise, maintenance wise?
_________________
Thank-you,
OGV.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Feb 19, 2003 6:18 pm    Post subject: Reply with quote

Ogv,

You cannot add a column in the middle without dropping the table.You can add columns at the end without dropping the table.

So in your case you must drop the table and re-create it.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ogv
Beginner


Joined: 23 Dec 2002
Posts: 10
Topics: 5
Location: NJ, USA

PostPosted: Wed Feb 19, 2003 6:22 pm    Post subject: Reply with quote

Kolusu,
Thanks for the imm replies.

My question is in detail here.

I am having the table as below.

Table-1
====
col1, col2, col3, col4, col5, col6

Having a composite primary key for the columns col1, col2, col6 will be a problem or not?

Our usual practises are having the first 2/3 columns as primary keys always?

Hope this query should be clear if not the above one.
_________________
Thank-you,
OGV.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Feb 19, 2003 6:40 pm    Post subject: Reply with quote

ogv,

Composite key is nothing but an ordered set of key columns of the same table.It is insignificant on the position of the key columns.The key columns need not be adjacent columns.

Performance wise it does not make any difference

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group