Professional Documents
Culture Documents
SQLLoader Basics
► About SQLLoader
► Data File
► SQLLoader Structure
► SQLLoader Registration as Concurrent Program
► Tools
Email : contact.leadtechnologies@gmail.com
About SQL*Loader
► SQL LOADER is an Oracle utility used to load data into table given a datafile which has the
records that need to be loaded. SQL*Loader takes data file, as well as a control file, to
insert data into the table. When a Control file is executed, it can create Three (3) files
called log file, bad file or reject file, discard file.
► Log file tells you the state of the tables and indexes and the number of logical records
already read from the input datafile. This information can be used to resume the load
where it left off.
► Bad file or reject file gives you the records that were rejected because of formatting errors
or because they caused Oracle errors.
► Discard file specifies the records that do not meet any of the loading criteria like when any
of the WHEN clauses specified in the control file. These records differ from rejected records
►
Email : contact.leadtechnologies@gmail.com
About SQL*Loader
► SQL*Loader is a bulk loader utility used for moving data from external files
into the Oracle database.
► It is a software utility provided with in Oracle Database
Email : contact.leadtechnologies@gmail.com
Main Components to consider before
design the interface
► Data File
► File Format (CSV/DATA/….etc)
► Fixed Length /Variable Length
► DataTypes of each column, width
► Frequency (per hour, per week, per month etc..)
► Location of the file
► Database Table
Email : contact.leadtechnologies@gmail.com
Structure of Data File – Fixed Length
► The data file can be in fixed record format or variable record format.
► Fixed Record Format would look like the below. In this case you give a specific position where the
Control file can expect a data field:
Email : contact.leadtechnologies@gmail.com
Structure of Data File –
Variable Length(Delimiter Based)
► Variable Record Format would like below where the data fields are separated by a
delimiter.
► Note: The Delimiter can be anything you like. In this case it is “|”
1196700|9|0|692.64
1378901|2|3900|488.62
1418700|2|2320|467.92
1418702|14|8740|4056.36
1499100|1|0|3.68
Email : contact.leadtechnologies@gmail.com
Structure of Control File
► LOAD DATA
► OPTIONALLY ENCLOSED BY ‘”‘ –the values of the data fields may be enclosed in “
Email : contact.leadtechnologies@gmail.com
Structure of Control File
► TRAILING NULLCOLS – columns that are not present in the record treated
as null
Email : contact.leadtechnologies@gmail.com
Structure of Control File
► INFILE * specifies that the data is found in the control file and not in an external file.
► INFILE ‘$FILE’, can be used to send the filepath and filename as a parameter when
registered as a concurrent program.
► INFILE ‘/home/vision/xxltech/GLData.csv’ specifies the filepath and the filename.
Email : contact.leadtechnologies@gmail.com
SQLLoader –
Example where datafile is an external file:
INFILE ‘/home/vision/kap/import2.csv’
Email : contact.leadtechnologies@gmail.com
SQLLoader –Sample1
Example where datafile is in the Control file:
LOAD DATA
INFILE *
INTO TABLE kap_emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name, deptno , deptname)
BEGINDATA
7369,SMITH,7902,Accounting
7499,ALLEN,7698,Sales
7521,WARD,7698,Accounting
Email : contact.leadtechnologies@gmail.com
SQLLoader
Example where file name and path is sent as a parameter when registered
as a concurrent program
LOAD DATA
INFILE ‘$FILE’
Email : contact.leadtechnologies@gmail.com
SQLLoader - TYPE OF LOADING:
► INSERT — If the table you are loading is empty, INSERT can be used.
► APPEND — If data already exists in the table, SQL*Loader appends the new rows to it.
If data doesn’t already exist, the new rows are simply loaded.
Email : contact.leadtechnologies@gmail.com
SQLLoader - TYPE OF LOADING:
► REPLACE — All rows in the table are deleted and the new data is loaded
Email : contact.leadtechnologies@gmail.com
SQLLoader
► OPTIONALLY ENCLOSED BY ‘”‘ specifies that data fields may also be enclosed by quotation marks.
► TRAILINGNULLCOLS clause tells SQL*Loader to treat any relatively positioned columns that are not
present in the record as null columns.
Load Data
–
–
–
TRAILING NULLCOLS
(
name Filler,
Empno ,
sal
)
Email : contact.leadtechnologies@gmail.com
SQLLoader - OPTIONS
OPTIONS (
SKIP=1,
ROWS=1000,
PARALLEL=true,
DIRECT=true,
SKIP_INDEX_MAINTENANCE=true
)
► ROWS is the number of row before committing (default:2)
► ERRORS controls the number of error allowed
► PARALLEL specifies whether direct loads can operate in multiple concurrent sessions to load data
► DIRECT specifies the load data path. A value of true specifies a direct path load. A value of false
specifies a conventional path load.
► SKIP_INDEX_MAINTENANCE will skip the maintenance (ie creation) of the index and is need with
direct path
Email : contact.leadtechnologies@gmail.com
SQLLoader – Command Line Keywords
userid--Oracleusername/password
control--Controlfilename
log--Logfilename
bad--Badfilename
data--Datafilename
discard--Discardfilename
discardmax--Numberofdiscardstoallow (Defaultall)
skip--Numberoflogicalrecordstoskip (Default0)
load--Numberoflogicalrecordstoload (Defaultall)
errors--Numberoferrorstoallow (Default50)
Email : contact.leadtechnologies@gmail.com
SQLLoader – Register as Concurrent
Program
Email : contact.leadtechnologies@gmail.com
SQLLoader – Register as Concurrent Program
Email : contact.leadtechnologies@gmail.com
Tools
► https://www.oracle.com/database/technologies/appdev/xe.html
Email : contact.leadtechnologies@gmail.com
Please Do Subscribe to My Channel
Please Do Provide Your Valuable Comments
Email : contact.leadtechnologies@gmail.com
Mobile : +91 7207 149 158 (WhatsApp)
Lea
YouTube Channel :
https://www.youtube.com/c/Srioracle
Technologi
d
Email : contact.leadtechnologies@gmail.com
es