Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 17 Nov 2005 @ 10:32:29 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: UPDATE vs DELETE-INSERT
 
From:   Agarwal, Rishi

David Micheletto wrote:

  If table1 is the target of many(?) updates, perhaps an insert select like the following might work better? (check the logic out carefully)  


          > INSERT newtable
          > SELECT a.col1, a.col2,

          >        case when b.col1 is null then a.col3

          >             else b.col3 end,
          >        case when b.col1 is null then a.col4

          >             else b.col4 end
          > from  table1 a left join table2 b
          > on    a.col1 = b.col1
          > and   a.col2 = b.col2

Assuming Table2 is the actual target table and Table1 has incremental data.

The SQL mentioned above will process the new records and load in into the new table. While applying this newtable to the final table Table2, we need to delete the existing records. Can we avoid DELETE here? Is this DELETE will be faster than UPDATE on Table2?



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023