Click to edit Master subtitle style
SQL Loader
Session Outline
SQL Loader : Description
SQL Loader : Components and Loader Control File
Logical Vs Physical Records
Data Conversion and Record Filtering
Logging Information and Log Files
SQL*Loader
SQL Loader can
Load data from multiple input datafiles
Handle different types of record formats
Manipulate data fields with SQL functions before inserting data into
database columns
Support a wide range of datatypes
Load multiple tables during the same run
SQL Loader
SQL Loader can
Combine multiple physical records into a single logical record
Handle a single physical record as multiple logical records
Thoroughly reports errors
Use high performance direct loads to load data directly into
the database
SQL Loader Components
SQL Loader Components
The basic components of SQL*Loader are:
Loader Control File
Input datafiles
Bad Files
Discard Files
Log Files
SQL Loader Control File
Example :
LOAD DATA
INFILE 'example.dat'
INTO TABLE emp
(empno POSITION(01:04) INTEGER EXTERNAL,
ename POSITION(06:15) CHAR,
job
POSITION(17:25) CHAR,
mgr
POSITION(27:30) INTEGER EXTERNAL,
sal
POSITION(32:39) DECIMAL EXTERNAL,
comm POSITION(41:48) DECIMAL EXTERNAL
Input Data Formats
Fixed Record FormatIn fixed format the data records all have the same fixed length format .That is, every
record is the same fixed length, and the data fields in each record have the same fixed
length, type, and position
Example
LOAD DATA
INFILE 'ulcase2.dat
INTO TABLE emp
(empno
POSITION(01:04) INTEGER EXTERNAL,
ename
POSITION(06:15) CHAR,
job
POSITION(17:25) CHAR,
deptno
POSITION(27:28) INTEGER EXTERNAL)
782 CLARK
MANAGER 10
783 KING
PRESIDENT 10
Logical v/s Physical Records
Distinction Between Logical and Physical Records
A record or line in a file (either of fixed length or terminated) is
considered a physical record whereas a logical record comprises
one or more physical records.Sometimes several physical records
must be combined to make one logical record
SQL*Loader allows you to compose logical records from multiple
records by using continuation fields. Physical records are
combined into a single logical record when some condition of the
continuation field is true
Data Conversion and Datatype
Specification
Discarded and Rejected
Records
Bad File
Bad file contains records rejected by SQL*Loader or by Oracle.
Records are rejected by SQL*Loader when the input format is
invalid
If Oracle determines that the row is valid, then the row is
inserted into the database. If not, the record is rejected and
SQL*Loader puts it into the bad file
Discard File
The discard file contains records that were filtered out of the
load because they did not match any record selection criteria
specified in the control file
Record Filtering
Log File and Logging
Information
When SQL Loader begins execution, it creates a log
file. If it cannot create a log file, execution terminates.
The log file contains a detailed summary of the load,
including a description of any errors that occurred
during the load