Page 1 of 1

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

Posted: Wed Dec 23, 2015 1:53 pm
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.

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

Posted: Wed Dec 23, 2015 3:19 pm
by nicc
Look at the syntax of the INSERT verb.

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

Posted: Wed Dec 23, 2015 3:23 pm
by zprogrammer
Also you could try UNLOAD and LOAD

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

Posted: Mon Dec 28, 2015 12:03 pm
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.

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

Posted: Mon Dec 28, 2015 12:42 pm
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