Sei sulla pagina 1di 2

SQL * LOADER:

==============
SQL*Loader to perform tasks such as:
=====================================
1) Loading data from multiple data files into multiple tables
2) Control various aspects of the load operation
3) Use either conventional or direct path loading

illustrates the flow of a typical SQL*Loader session:


=============================================

When skip option is not mentioned in the control file, even though the header of the input CSV file will
be rejected and sent to bad file as it’s not the same file format of the stage table.
If skip is mentioned then there won’t be any rejected columns in the bad file.
Skip we can mention also in the CMD prompt.
If insert or append or replace is not mentioned in the CTL, then by default it will do the insert option.
If we are appending the same record which are already available in the database, then append won’t
work.
We need to mention the keyword position while loading with fixed with data format.
When uploading data into tables from single flat file, if we are appending, then if any one of the two
tables is already having the same data, appending won’t happen for the two tables itself.
When truncating data from two database tables and if any one of the table is already empty then
truncate won’t happen for the two tables itself.

There are two types of data format in Control file:


==========================================
Delimited data format - 001,selva,accounts,manager
Fixed width data format – 001selvaaccountsmanager
We can upload .csv,.dat,.txt
Contents of Log file :
=======================
Path locations of ctl, data file,bad file, discard file.
No of rows loaded successfully, no of rows not loaded due to failure.

Bad file :
===========
contain the rejected records which are not uploaded into the database due to any error
in records(like wrong datatype)

Discard file :
===============
contain the discarded records which doesn't meet the when condition and not uploaded
into the database. If no records are discarded then discard file is not created.
To create a discard file from within a control file, specify any of the following:
 DISCARDFILE filename, DISCARDDN filename (DB2), DISCARDS, or DISCARDMAX.
To create a discard file from the command line, specify either DISCARD or DISCARDMAX.
The discard file is created in the same record and file format as the datafile

EXAMPLE:
==========
control.ctl:
=============
load data
infile 'C:\Users\GIRI\Desktop\selva\dept.csv'
append
into table dept_v
(
dept_no position(1:2)
,dept_name position(3:9)
)

-- cmd query : C:\Users\GIRI>sqlldr miscn/apps123 control='C:\Users\GIRI\Desktop\selva\control.ctl'

DEPT IN CSV FILE:


===================
dept_no dept_name
10 Medical
20 Transport

Different scenarios of SQL LDR


https://www.thegeekstuff.com/2012/06/oracle-sqlldr/

Potrebbero piacerti anche