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 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 Data replication from multiple Db2 ta... kishpra DB2 1 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
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


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