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

Insert a column in the middle of the table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top