Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 10256
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: 10256
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 unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us