Beruflich Dokumente
Kultur Dokumente
Sql *Loader
Control File
It controls the Behavior of Sql *Loader
Source of Data to be loaded
Destination of Data to be loaded
Filtering of Data before Loading
Transformation of Data before Loading
Relating the Data file fields to table
columns
5
Log File
Log
File
SQL *Loader
Bad
File
Discard
File
DataBase
Loading Method
Basically there are 3 Loading Methods
Conventional Path Load
Direct Path Load
External Table Load( from Oracle 9i).
PARALLEL Loading
12
Advantage :
Very High Speed
Disadvantage :
Cannot Load Object Types,
Collection Types (Nested Table,
VARRAY),LOB(CLOB,NCLOB,BLOB,
BFILE)
13
Field Conversion
DATA
FILE
Field 1
b b b
a a a
CHAR(5)
BIND
ARRAY
Field 2
aaa
CHAR(5)
SQL
LOADER
bbb
Table
DATABASE
Column 1
Column 2
a a a_ _
bbb
CHAR(5)
SERVER
VARCHAR(5)
14
Record Filtering
Record in
Data file
Database
Read in
Control
file
SQL *Loader
Field Processing
Accepted
Discard Discarded
File
SQL *Loader
When-clause
Evaluation
Rej
ec
ted
Bad
File
Selected
Re
je
Inserted
ct e
Database
Server
15
16
12
7891
1234
3456
0111
3333
17
18
control2.ctl
load data
infile 'data2.dat'
insert
into table sql_ldr2 replace
(
n1 position(1:3),
n2 position(5:7),
n3 position(9:11)
)
Sql_ldr2:
N1 N2 N3
111 222 666
333 444 666
555 666 666
777 888 666
999 000 666
19
Appending to a table
Sql_ldr3 ( Before Loading):
--------------------------------N1
N2
N3
------ --------- --------111
222
666
333
444
666
555
666
666
777
888
666
999
0
666
data3.dat
111 222 666
333 444 666
555 666 666
777 888 666
999 000 666
control3.ctl
load data
infile 'data3.dat'
insert
into table sql_ldr3 append
(
n1 position(1:3),
n2 position(5:7),
n3 position(9:11)
)
20
Sql_ldr4:
N1
N2
--------- --------111
222
111
222
111
222
data4.dis
333 444
333 444
21
Field Separator
data5.dat
1111;2222;
3333;4444;
1111;2222;
3333;4444;
1111;2222;
control5.ctl
load data
infile 'data5.dat'
insert
into table sql_ldr5 replace
when n2='2222'
fields terminated by ';'
(
n1 integer external,
n2 integer external
)
Sql_ldr5
N1
N2
-------- --------1111 2222
1111 2222
1111 2222
22
control9.ctl
load data
$
infile 'data91.dat'
infile 'data92.dat'
insert into
table sql_ldr9 replace
(
n1 position(1:2),
n2 position(4:5)
)
Sql_ldr9
N1
11
33
55
77
99
11
N2
22
44
66
88
0
11
23
control10.ctl
load data
infile 'data10.dat'
insert into
table sql_ldr101 replace
(n1 position(1:2),
n2 position(4:5))
into
table sql_ldr102 replace
(n1 position(1:2),
n2 position(4:5))
Sql_ldr101
Sql_ldr102
N1
11
33
55
N1
11
33
55
N2
22
44
66
N2
22
44
66
24
data111.dat
11 22
33 44
55 66
25
Skipping records
data2.dat
111 222 666
333 444 666
555 666 666
777 888 666
999 000 666
control2.ctl
load data
infile 'data2.dat'
insert
into table sql_ldr2 replace
(
n1 position(1:3),
n2 position(5:7),
n3 position(9:11)
)
Sql_ldr2
N1 N2 N3
555 666 666
777 888 666
999 000 666
26
Sql_ldr14:
A1
A2
aa
cc
bbb
ddd
27
control12.dat
load data
infile 'data12.dat' "fix 5"
insert
into table sql_ldr12 replace
fields terminated by ','
(
n1 integer external,
n2 integer external
)
Sql_ldr12:
N1
12
56
91
N2
34
78
1
28
data1.dat
07aaa,bbb08ccc,dddd05ee,ff
control1.ctl
load data
$ sqlldr control=control1.ctl userid=apps/secretone
infile data1.dat var 02
Sql_ldr11:
into table sql_ldr1
fields terminated by ,
A1
A2
(
aaa
bbb
a1 char,
ccc
dddd
a2 char
ee
ff
);
29
Desc sql_ldr1
a1 Varchar2(10)
a2 Varchar2(10)
Control2.ctl
$ sqlldr control=control2.ctl userid=apps/secretone
load data
Sql_ldr12:
infile data2.dat str |
into table sql_ldr2
A1
A2
fields terminated by ,
aaa
bbb
(
ccc
dddd
a1 char,
eeee
ffff
a2 char
)
30
BAD - Specifies the file in which all bad data is kept. The default
filename is the control filename with a .bad extension.
31
32
ROWS No: of rows to put in the path bind array, for Conventional
path load. For Direct path load, ROWS specifies the no: of rows to
read before a data save is performed. Default value is 64 in
Conventional Path.
SKIP No: of record to skip before starting the load. This parameter is
important for restarting a load process after stopping an earlier session.
Useful in Recovery from failure.
33
USERID Specifies the username and password for the user conducting the SQL
*Loader session
SILENT Allows to suppress various header and feedback messages that SQL
*Loader normally displays during a Load session.
34
35