Re: Large Table Update/Merge problem

From: Pratap <pratap_fin_at_rediffmail.com>
Date: 18 Aug 2004 21:52:38 -0700
Message-ID: <830861d2.0408182052.49a48bad_at_posting.google.com>


Do the update first.

update
(

select a.col1 acol1, b.col1 bcol1
from a, b
where a.key = b.key
)
set acol1 = bcol1

make sure you have unique key on the "key" columns of both tables.

Then go for the insert -

insert into b select * from a where not exists
(

select null from b where a.key = b.key
)

You may need to set statistics on the temporary tables to get an efficient plan.
(Cannot gather statistics on temporary tables)

Pratap Deshmukh
Cognizant Technology Solutions, India Received on Thu Aug 19 2004 - 06:52:38 CEST

Original text of this message