View previous topic :: View next topic |
Author |
Message |
Ogv Beginner
Joined: 23 Dec 2002 Posts: 10 Topics: 5 Location: NJ, USA
|
Posted: Wed Feb 19, 2003 6:12 pm Post subject: Add new Column to the composite PrimaryKey |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Feb 19, 2003 6:18 pm Post subject: |
|
|
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 |
|
|
Ogv Beginner
Joined: 23 Dec 2002 Posts: 10 Topics: 5 Location: NJ, USA
|
Posted: Wed Feb 19, 2003 6:22 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Feb 19, 2003 6:40 pm Post subject: |
|
|
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 |
|
|
|
|