Friday, 22 September 2017

SQL LOADER


SQL Loader :

--Its a bulk loader utility
--SQL Loader is used to loads data from flat file into a oracle table.
--High Performance Data Loads

Step 1: Input is CSV,DAT,FLAT File 
Step 2: Creation of CTL File [CTL : Control File]
Step 3: Open in a Command Prompt.
Step 4: SQLLDR username/Password
Step 5: Pathname of the CTL File.

Step 1: Report1.CSV

Step 2: load data 
        infile " FILE PATH OF THE CSV FILE "
        into table table name 
fields terminated by ',' optionally enclosed by ' " '
(Column 1, column 2...Column n) 
-- Save the file name as FILENAME.CTL extension

Step 3: Open in Command Prompt
Step 4: SQLLDR Username/Password 
Step 5: CONTROL = Path Name Of the CTL File .

Finally 

Commit point reached - logical record count Total number of record .

CREATE table load (first_name varchar2(20),Salary Number);

Table Created.

SELECT * FROM Newload;

No Rows Selected

SELECT * FROM load;

FIRST_NAME               SALARY
-------------------- ----------
Den                       11000
Alexander                  3100
Shelli                     2900
Sigal                      2800
Guy                        2600
Karen                      2500
Susan                      6500
parthi                     2000
parthi                     2000

The above file is converted into the CSV File format Named as newreport.csv

CTL File Creation Syntax

load data
infile 'C:\sql notes\Class\newreport.csv'  
into table newload
fields terminated by ',' optionally enclosed by '"'
(First_name, Salary )

The File is saved as newload.CTL extention.

Open Command Prompt

SQLLDR HR/ADMIN

CONTROL = "CONTROL FILE PATH NAME"

Select * from Newload;

10 rows selected

Bad File -- its contain information about the missing datas.
log File -- Information about the records to be inserted log on time execution time.
CSV File -- Common Separated Value file.
CTL File -- Control File.

Inserting new data into the old table via SQL LOADER makes an error.

Two Types

Conventional Path LOAD -- used in table partition
Direct Path LOAD--  Directly load the data in table

Its not a oracle utility
Performance wise SQLLOADER is more faster than external table 
External table is oracle utility.

No comments:

Post a Comment