| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

04-22-09, 12:16
|
|
Registered User
|
|
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
|
|
|
transfer (insert) data from one table to another table
|
|
2 tables have almost same structure but table2 has additional col - PROD_ID. How do I transfer data from table1 to table2 and set PROD_ID to 'XXX' at the same time? This what i have but i don't think it's right:
insert data into DBA.table2
from (
PROD_ID = ‘XXX’
, select * from DBA.XXX_table1);
thanks in advance
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
|
|

04-22-09, 12:18
|
|
Registered User
|
|
Join Date: Dec 2008
Posts: 76
|
|
insert into table2(prod_id, a,b,c,d) select 'xxx', a, b, c, d from table1
|
Last edited by rdutton; 04-22-09 at 12:22.
|

04-22-09, 13:18
|
|
Registered User
|
|
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
|
|
|
|
Quote:
|
Originally Posted by rdutton
insert into table2(prod_id, a,b,c,d) select 'xxx', a, b, c, d from table1
|
I did not want to list all cols from table1 as there are many, but it is ok. Thanks so much
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
|
|

04-22-09, 13:26
|
|
Registered User
|
|
Join Date: Feb 2008
Location: Japan
Posts: 2,193
|
|
If columns of table2 are same as table1 except adding prod_id at the first or last, you may want to do like:
insert into table2 select 'xxx', t1.* from table1 t1
or
insert into table2 select t1.*, 'xxx' from table1 t1
|
|

04-23-09, 09:20
|
|
Registered User
|
|
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
|
|
it did work. thanks
now there are 32,000,000 rows in table1 so when i submit this statement i run into a problem:
During SQL processing it returned: SQL0964C The transaction log for the database is full. SQLSTATE=57011
I increased db cfg params:
LOGFILSIZ = 4096 (from 1024)
LOGPRIMARY) = 60 (from 20)
LOGSECOND) = 40 (from 10)
but still getting this error. And I understand I can not commit while I am doing inserts. How do I resolve this?
Thanks
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
|
|

04-23-09, 09:52
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
You can use an EXPORT to export the data, then use IMPORT with COMMITCOUNT to insert the data.
Andy
|
|

04-23-09, 12:00
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 12
|
|
You can use Load from cursor.
declare mycur cursor for select XXX,..... from tab1
load from mycur of cursor insert into tab2 nonrecoverable
|
|

04-24-09, 04:53
|
|
Registered User
|
|
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
|
|
Since V8 DB2 has "MERGE". Answers to a lot of problems, also this one 
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|