Thursday, January 9, 2014

SQL Loader Tutorial


 
SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. Its syntax is similar to that of the DB2 load utility, but comes with more options. SQL*Loader supports various load formats, selective loading, and multi-table loads.


SQL Loader Needs

1.       SQL File

2.       CTL (Control) File

3.       CSV (Data) File

4.       SQL Loader Command


Sample codes and Screenshots are given below.

SQL Loader Command



sqlldr userid = apps/apps@ebs121.gapblue.com:1521/vis control = 'gb_sample.ctl' data = 'gb_sample.csv'

 

1.SQL File

create table gb_sample

         (

         stats_type varchar2(100),

            STATS_NAME  varchar2(100),

            VALUE1      number  ,

            VALUE2      number  ,

            VALUE3      number  ,

            VALUE4      number  ,

            VALUE5      number  ,

            VALUE6      number

            );

2. Control File CTL

load data

infile *

append

into table gb_sample

FIELDS TERMINATED BY ','

trailing nullcols

(stats_type,

 STATS_NAME    ,

 VALUE1        ,

 VALUE2        ,

 VALUE3        ,

 VALUE4        ,

 VALUE5        ,

 VALUE6

)

3.CSV Data File

STATS_NAME
VALUE1
VALUE2
VALUE3
VALUE4
VALUE5
VALUE6
unni
10
20
30
40
50
60
test1
10
20
30
40
50
60
test2
10
20
30
40
50
60
test3
10
20
30
40
50
60

 

 

 

 

No comments:

Post a Comment