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
 

 

inserting one column from one table to another table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: inserting one column from one table to another table
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    Post subject:
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    Post subject:
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    Post subject:
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: 680
Location: NJ

PostPosted: Tue Nov 08, 2005 12:42 pm    Post subject: insert
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    Post subject:
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    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 Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts unload data from table with lob columns farhad_evan DB2 1 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 Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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