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 column in the middle of the table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
lakshmibala

New User


Joined: 16 Jun 2004
Posts: 47

PostPosted: Mon Nov 01, 2004 12:01 pm    Post subject: Insert a column in the middle of the table
Reply with quote

Hi all

i have a doubt, can v insert a column in a table, is it possible to insert a column in the middle of the table?


Regards
Lakshmi
Back to top
View user's profile Send private message

jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Tue Nov 16, 2004 8:45 pm    Post subject:
Reply with quote

Hi,

Yes you can do that, the procedure is first drop the table and then create
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Thu Dec 09, 2004 2:35 pm    Post subject: Try it out...
Reply with quote

Hi,

We can add a new column using ALTER TABLE but not in the middle. We can do it by using one indirect method that is...

for example i have a table EMP with following columns
EMPNO,ENAME,JOB,DOB,DEPTNO

You want to insert a column SAL between JOB and DOB then apply the following steps...

ALTER TABLE EMP ADD COLUMN SAL NUMBER(5,2);
this will add SAL column at end. then create a view as follows...

CREATE VIEW EMPVIEW AS SELECT EMPNO,ENAME,JOB,SAL,DOB,DEPTNO;

and use the view instead of table ok...

Bye,
O.V.Reddy.
Back to top
View user's profile Send private message
karuna

New User


Joined: 03 May 2005
Posts: 10
Location: bangalore

PostPosted: Wed May 18, 2005 5:26 pm    Post subject: Re: Try it out...
Reply with quote

Hi ovreddy,


what is NUMBER(5,2) in the Alter query below?Is this col no.?





ovreddy wrote:
Hi,

We can add a new column using ALTER TABLE but not in the middle. We can do it by using one indirect method that is...

for example i have a table EMP with following columns
EMPNO,ENAME,JOB,DOB,DEPTNO

You want to insert a column SAL between JOB and DOB then apply the following steps...

ALTER TABLE EMP ADD COLUMN SAL NUMBER(5,2);
this will add SAL column at end. then create a view as follows...

CREATE VIEW EMPVIEW AS SELECT EMPNO,ENAME,JOB,SAL,DOB,DEPTNO;

and use the view instead of table ok...

Bye,
O.V.Reddy.
Back to top
View user's profile Send private message
vasanthanc

New User


Joined: 01 Apr 2005
Posts: 58

PostPosted: Thu May 19, 2005 11:04 am    Post subject:
Reply with quote

Karuna,

NUMBER is the data type of the field salary and (5,2) is the size of the field
Back to top
View user's profile Send private message
karuna

New User


Joined: 03 May 2005
Posts: 10
Location: bangalore

PostPosted: Sat May 21, 2005 11:31 am    Post subject:
Reply with quote

vasanthanc wrote:
Karuna,

NUMBER is the data type of the field salary and (5,2) is the size of the field



Vasanthac,


I know about Integer data type but i have never heard and used NUMBER data type thats y m asking.


Karuna
Back to top
View user's profile Send private message
ursjohn

New User


Joined: 25 Apr 2005
Posts: 5
Location: india

PostPosted: Mon May 23, 2005 11:10 am    Post subject:
Reply with quote

It is not possible to insert into middle records
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