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

Insert a new column at the middle of the table


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

New User


Joined: 25 Sep 2009
Posts: 9
Location: Bangalore

PostPosted: Wed Jun 02, 2010 12:01 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10903
Location: italy

PostPosted: Wed Jun 02, 2010 12:03 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
eprasad629

New User


Joined: 25 Sep 2009
Posts: 9
Location: Bangalore

PostPosted: Wed Jun 02, 2010 12:11 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10903
Location: italy

PostPosted: Wed Jun 02, 2010 12:20 pm
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Jun 03, 2010 2:46 pm
Reply with quote

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
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts count contained values of several col... DB2 5
No new posts Filter records where condition is in ... SYNCSORT 6
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Extract ISPF table column headings CLIST & REXX 2
Search our Forums:


Back to Top