Difference Between Insert and Append statement in SQL Loader?

Rajesh Kumar G picture Rajesh Kumar G · Jan 27, 2011 · Viewed 50.5k times · Source

Can any one tell me the Difference Between Insert and Append statement in SQL Loader?consider the below example : Here is my control file

     load_1.ctl
     load data 
     infile 'load_1.dat' "str '\r\n'" 
     insert*/+append/* into table sql_loader_1 
     ( 
      load_time sysdate, 
      field_2 position( 1:10),
      field_1 position(11:20)
     ) 

Here is my data file

     load_1.dat
     0123456789abcdefghij
     **********##########
     foo         bar
     here comes a very long line 
     and the next is 
     short 

Answer

Alex Poole picture Alex Poole · Jan 27, 2011

The documentation is fairly clear; use INSERT when you're loading into an empty table, and APPEND when adding rows to a table that (might) contains data (that you want to keep).

APPEND will still work if your table is empty. INSERT might be safer if you're expecting the table to be empty, as it will error if that isn't true, possibly avoiding unexpected results (particularly if you don't notice and don't get other errors like unique index constraint violations) and/or a post-load data cleanse.