Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between Insert and Append statement in SQL Loader?

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 
like image 547
Rajesh Kumar G Avatar asked Jan 27 '11 04:01

Rajesh Kumar G


1 Answers

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.

like image 140
Alex Poole Avatar answered Sep 27 '22 16:09

Alex Poole