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

inserting one column from one table to another table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mani_shankh

New User


Joined: 27 Apr 2005
Posts: 2
Location: new delhi

PostPosted: Sat May 07, 2005 11:23 am
Reply with quote

hi....

i want to insert data from one column of a table to another column of another table. the datatype and data length of both columns of the tables are same.
is it possible and if possible then how?

help appreciated.
thanx :roll:
Back to top
View user's profile Send private message
gnagakishore

New User


Joined: 26 Mar 2005
Posts: 25
Location: Hyderabad

PostPosted: Sat May 07, 2005 10:33 pm
Reply with quote

u can create view from both the tables so that the view may contain
the required column
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: Sun May 15, 2005 12:45 pm
Reply with quote

Hi Mani,

You can use an insert statement as follows...

TO INSERT ONLY ONE COLUMN:

INSERT INTO TAB1(COL1) SELECT COL2 FROM TAB2 WHERE <COND>;

TO INSERT ALL COLUMNS:
INSERT INTO TAB1 SELECT * FROM TAB2 WHERE <COND>;
(BOTH TAB1 AND TAB2 HAVE THE SAME STRUCTURE)

Thanks,
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:57 am
Reply with quote

but mani, u didnt mention about the other columns. Are there values in other columns and u need to insert data in existing records or to insert them as new records??
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Tue Nov 08, 2005 12:42 pm
Reply with quote

hi frnd,
since inserting the data in two tables with same field is easy as like

insert into tablename values(select ....);

if any particular column is to be inserted check ur constraint and then insert bcz of null value in other fields will throw some error.
Back to top
View user's profile Send private message
paulstephen

New User


Joined: 20 Oct 2005
Posts: 20
Location: Chennai

PostPosted: Tue Nov 08, 2005 3:44 pm
Reply with quote

Set some triggers
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