0% found this document useful (0 votes)
2 views

SQL Loader

SQL * Loader is a tool for loading data from external files into Oracle Database tables, utilizing a control file to specify data source and parsing instructions. It generates log, discard, and bad files to manage the loading process and handle errors. The loading can be performed using conventional or direct path methods, with direct path loading being faster than conventional loading.

Uploaded by

shalih786
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Loader

SQL * Loader is a tool for loading data from external files into Oracle Database tables, utilizing a control file to specify data source and parsing instructions. It generates log, discard, and bad files to manage the loading process and handle errors. The loading can be performed using conventional or direct path methods, with direct path loading being faster than conventional loading.

Uploaded by

shalih786
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL * Loader loads data from external files into tables of a Oracle Database.

It has a powerful data parsing engine that puts little limitation on the format of
data in the file.

Concept of SQL * Loader:

Input File(Data File)

 SQL * Loader reads data from one or more files that are specified in the control
file.
 A Particular data file can be in fixed record format, variable record format, or
stream
record format.
 The record format can be specified in the control file with the INFILE parameter.

 Control File

 The Control File is a Text file that is written in a language that SQL * Loader
Understands.
 The Control File indicates to SQL * Loader where to Find the data, how to parse
and
interpret the data, where to insert the Data.

 Log File

 When the SQL * Loader begin execution, it creates a log file. If it cannot create
a log file,
execution terminates.
 The log file contains detailed summary of a load, including a description of any
errors
that occurred during the load.

 Discard File

 The file is created only when it is needed and only if you have specified that a
discard
file should be enabled.
 The Discard file contains records that are filtered out of the load because they
do not
match any record - selection criteria specified in the control file

Bad File

 The Bad file contains records that are rejected, either by SQL * Loader or by the
Oracle
Database.
 Data file records are rejected by the SQL * Loader when the input format is
invalid.
 After the data file record is accepted for processing by SQL * Loader, it is sent
to the
Oracle Database for inserting into a table as a row.

SQL * Loader Three Steps:


------------------------

 Creating the Table in Oracle Database.


 Write the Control File -> .CTL Format.
 Write the Data File -> .CSV Format (.Dat Format).

Table in Oracle Database Example:


--------------------------------

CREATE TABLE employee(EMP_ID NUMBER,


EMP_NAME VARCHAR2(50),
DEPT_ID NUMBER);

Control File(.CTL Format) Example:


---------------------------------

OPTIONS(DIRECT = FALSE,SKIP = 1, ERRORS=50,PARALLEL = FALSE,ROWS = 5)


LOAD DATA
INFILE 'E:\oracle\plsql channel\SQL Loader\Code\emp_data.CSV'
TRUNCATE -- INSERT REPLACE APPEND TRUNCATE
INTO TABLE employee
fields terminated by ","
Trailing nullcols
(
emp_id,
emp_name "UPPER(:EMP_NAME)",
dept_id
)

Data File Example (.CSV Format):


-------------------------------

1,Raja,EEE
2,Tamil,ECE,
3,Arjun,CSE

Open Sql and Following Steps Below:


-----------------------------------

SQL -> CONN USERNAME/PASSWORD@DATABASE


Connceted.
SQL -> SQLLDR CONTROL * E:\oracle\plsql channel\SQL Loader\Code\emp_data.CTL
USERID = USERNAME/PASSWORD@DATABASE;

Types of Sql Loader Path:


-------------------------

 Conventional Path Loading. -> OPTIONS(DIRECT = FALSE ,SKIP = 1,


ERRORS=50,PARALLEL = FALSE,ROWS = 5)
 Direct Path Loading. -> OPTIONS(DIRECT = TRUE ,SKIP = 1, ERRORS=50,PARALLEL =
FALSE,ROWS = 5)

Conventional Path Loading:

 SQL Loader -> Oracle file -> Oracle Database.


 It takes more time than compare to direct path loading.
Elapsed time as : 00:00:00:34.
CPU time as : 00:00:00:09.

Direct Path Loading:


 SQL Loader -> Oracle Database.
 It takes less time than compare to conventional path loading.
Elapsed time as : 00:00:00:24.
CPU time as : 00:00:00:10.

You might also like