Insert data from one table to another in DB2 on mainframes.

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
Post Reply
Sushma Rahul
Registered Member
Posts: 11
Joined: Tue Dec 22, 2015 2:30 pm

Insert data from one table to another in DB2 on mainframes.

Post by Sushma Rahul »

Hi,

I have two tables. Table-X and Table-Y. Both tables have same number of columns and of same data type for the columns in them. Basically they are replica of each other. Now, I need to copy the rows from Table-X to Table-Y. I think I can use INSERT in a different way here so that using a single INSERT I can use update both the tables. Please guide, if using a single insert I can take data from Table-X and copy it in to Table Y? Any pointers are greatly appreciated.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Insert data from one table to another in DB2 on mainframes.

Post by nicc »

Look at the syntax of the INSERT verb.
Regards
Nic
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Insert data from one table to another in DB2 on mainframes.

Post by zprogrammer »

Also you could try UNLOAD and LOAD
zprogrammer
Sushma Rahul
Registered Member
Posts: 11
Joined: Tue Dec 22, 2015 2:30 pm

Re: Insert data from one table to another in DB2 on mainframes.

Post by Sushma Rahul »

Pandora-Box wrote:Also you could try UNLOAD and LOAD
Thanks. I can do that but I am thinking if we can use INSERT itself to do that. I am reading through the INSERT statement to make it work. Thanks for the answers.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Insert data from one table to another in DB2 on mainframes.

Post by zprogrammer »

As Nicc mentioned you could use insert statement

But if there are more records it is better to have frequent commits or as an alternative you could unload and load data
zprogrammer
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”