You are on page 1of 10

Let Us Understand Oracle SQL*Loader

Sunday, December 11, 2016

Oracle Apps R12 By Satish K Yellanki (SkyEss Techno Solutions Pvt. Ltd.)

Slide : 1

SQL*Loader in Short Called As SQLLDR is The Utility To


Use For High Performance Data Loads.
The Data Can Be Loaded From Any Text File And Then it
Can Be Inserted into The Database.
SQL*Loader Reads A Data File And A Description of The
Data Which is Defined in The Control File.
Using The Information From The Control File And Any
Additional Specified Parameters Which Can Be Specified
Either on The Command Line OR in The Parameter File
SQL*Loader Loads The Data into The Database.
During Processing, SQL*Loader Writes
Messages To The Log File
Bad Rows To The Bad File
Discarded Rows To The Discard File
Features of SQL*Loader
Has A Powerful Data Parsing Engine Which Puts Little
Limitation on The Format of The Data in The Data File.
Can Load Data From Multiple Datafiles During The Same
Load Session.
Can Load Data into Multiple Tables During The Same
Load Session.

It is Character Set Aware, We Can Specify The Character


Set of The Data.
Can Selectively Load Data, We Can Load Records Based
on The Records' Values.
Can Manipulate The Data Before Loading it, Using SQL
Functions.
Can Generate Unique Sequential Key Values in Specified
Columns.
Can Use The Operating System's File System To Access
The Data File(s).
Can Load Data From Disk, Tape, OR Named Pipe.
Does Sophisticated Error Reporting Which Greatly Aids
Troubleshooting.
Supports Two Loading "Paths"
Conventional Path
Direct Path
Note
Conventional Path Loading is Very Flexibility, Direct Path
Loading Provides Superior Loading Performance.
Can Load Arbitrarily Complex Object-Relational Data.
Supports Secondary Datafiles For Loading of LOBS And
Collections.

To A Large Degree it is Compatible With The DB2 Load


Utility From IBM Hence Consequently, With No OR Few
Changes A DB2 Load Utility Control File Can Be Used As A
SQL*Loader Control File.
Input
Data
Files

Loader
Control
File

Log
File

Tables

SQL*Loader

Bad
Files

Discard
Files

Database

Indexes

SQL*Loader Architecture

SQL*Loader Inputs
Control File, Which Controls The Behavior of SQL*Loader
One OR More Datafiles
SQL*Loader Outputs
Oracle Database Where The Data is Loaded
A Log File
A Bad File
A Discard File
Log File
Log File Tells Us The State of The Tables And Indexes
And The Number of Logical Records Already Read From
The Input Data File.
The Log File Information Can Be Used To Resume The
Load Where it as Left off Previously.
Bad File OR Reject File
Bad File OR Reject File Gives Us The Records That Were
Rejected Because of Formatting Errors OR Because They
Caused Oracle Errors.
Discard File
Discard File Specifies The Records That Do Not Meet Any
of The Loading Criteria Specified in The Control File.
The Records in Discard File Differ From Rejected Records.

Structure of The Data File


The Data File Can Be in Fixed Record Format OR Variable
Record Format.
Fixed Record Format
Fixed Record Format Follows A Fixed Length For An
Attribute, In This Case We Give A Specific Position Where
The Control File Can Expect A Data Field.
Variable Record Format
Variable Record Format Follows A Delimiter Concept,
Where The Data Fields Are Separated By A Delimiter.
The Delimiter Can Be Anything The User Defines, Usually
The Delimiter Will Be A Comma , OR Pipe Symbol |
Structure of a Control File
The SQL*Loader Control File Contains Information That
Describes How The Data Will Be Loaded.
The Main Components of The Control File
The Table Name
The Column Names With Datatypes
Field Delimiters
Control File Provides All The Technical Information
Needed For The Total SQL*Loader Processing.
Control File Can Be Created Manually.

Manually Creating Control Files is An Error-Prone


Process.
SQL Script Methodology Can Be Used To Generate An
Accurate Control File For A Given Table.
The SQL Script Generally Accepts A Table Name And A
Date Format Which is Used For Date Columns, And
Generates A Valid Control File To Use With SQL*Loader
For That Table.
Control File Contents
The SQL*Loader Control File is A Text File That Contains
Data Definition Language (DDL) Instructions.
DDL is Used To Control The Following Aspects of A
SQL*Loader Session
Where SQL*Loader Will Find The Data To Load
How SQL*Loader Expects That Data To Be Formatted
How SQL*Loader Will Be Configured Specific To As it
Loads The Data
Memory Management
Rejecting Records
Interrupted Load Handling
How SQL*Loader Will Manipulate The Data Being
Loaded

The Control File Has Three Main Sections


Session-Wide Information
Table And Field-List Information
Input Data Which is Optional Section
SQL*Loader Command-Line Parameters
Command Line
Parameter

Description

USERID

Oracle USERID and PASSWORD

CONTROL

Control Filename

LOG

Log Filename

BAD

Bad Filename

DATA

Datafile Name

DISCARD

Discard Filename

DISCARDS

Number of Discards To Terminate The Load (Default: ALL)

SKIP

Number of Logical Records To Skip (Default: 0)

LOAD

Number of Logical Records To Load (Default: ALL)

ERRORS

Number of errors to terminate the load (default: 50)

ROWS

Number of Rows in The Conventional Path Bind Array OR Between


Direct Path Data Saves (Conventional Path: 64, Direct Path: ALL)

BINDSIZE

Size of Conventional Path Bind Array in BYTES

SILENT

Suppress Messages Between Run (Header, Feedback, Errors,


Discards)

Command Line
Parameter

Description

DIRECT

Use Direct Path Load (Default: FALSE)

PARFILE

Parameter Filename

PARALLEL

Perform Parallel Load (Default: FALSE)

FILE

Datafile To Allocate Extents

Illustrative Examples

SQLLDR SCOTT/TIGER Load.CTL Load.LOG Load.BAD Load.DAT


SQLLDR USERID=SCOTT/TIGER CONTROL=Load.CTL DATA=Load.DAT
SQLLDR SCOTT/TIGER Load.CTL DATA=Load.DAT

SQLLDR PARFILE=Load.PAR

Note
Command-Line Parameters Can Be Placed in A Parameter
File in Short Called As ParFile And Can Be Referenced on
The Command Line.
Illustrative Example
Pseudo Structure of Parameter File
DATA=Load.DAT
USERID=SCOTT/TIGER
CONTROL=Load.CTL
LOG=Load.LOG
BAD=Load.BAD
DISCARD=Load.DSC

SQL Loader Data Types


CHAR
DECIMAL EXTERNAL
INTEGER EXTERNAL
SQL Loader Modes OR LOAD TYPES
APPEND
INSERT
REPLACE
TRUNCATE

You might also like