|
View previous topic :: View next topic
|
| Author |
Message |
eprasad629
New User
Joined: 25 Sep 2009 Posts: 9 Location: Bangalore
|
|
|
|
Hi,
Is it possible to insert a new column at the middle of the table? Say, I have a table ABC which has 6 columns, I need to insert a new column at 4th position.
Many thanks in advance.
Regards,
Praelay. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
why in the middle ?
the way data is accessed in db2 makes irrelevant the column position
anyway DB2 stores columns according to it's own rules
You would have to read and understand the DB2 internals to find out
the rules for data placement aligning inside a row
an added column<might> come <after> the previously defined ones
DB2 defines what <after>, <before>, <middle>, <between> mean  |
|
| Back to top |
|
 |
eprasad629
New User
Joined: 25 Sep 2009 Posts: 9 Location: Bangalore
|
|
|
|
Hi Enrico,
Thanks for a swift response.
I agree with you. However, just want to know whether DB2 allows a user to create a column in the middle of a table.
BTW, If I change the COLNO field in SYSIBM.SYSCOLUMNS table for a TBNAME, can I see any change with the table fields order?
Many thanks in advance. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
Do You really think that a manual update to the catalog tables would be a good idea?
meditate please, meditate
if it is just a curiosity ok,
but it would be certainly a silly business requirement |
|
| Back to top |
|
 |
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
| enrico-sorichetti wrote: |
why in the middle ?
the way data is accessed in db2 makes irrelevant the column position
|
up until DB2 9 (and even in DB2 9 without RRF) it is advised to put varchars at the end of the row for performance reasons (I could explain, but it is well documented all over the internet)
So when a new (non-varchar) column needs to be added it could be wise to put it before the varchar-columns.
Unfortenately this still involves a unload/drop/create/reload.
I never tried (for obvious reasons) to update the colno in the catalog. I would hope DB2 doesn't allow this. |
|
| Back to top |
|
 |
|
|