Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Insert a new column at the middle of the table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Insert a new column at the middle of the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Wed Jun 02, 2010 12:03 pm    Post subject: Reply to: Column Insert
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Wed Jun 02, 2010 12:20 pm    Post subject: Reply to: Column Insert
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    Post subject: Re: Reply to: Column Insert
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us