Friday, March 21, 2008

Loading files form a sql loader

Loading files form a sql loader

SQL*Loader is an Oracle-supplied utility that allows you to load data from a flat
file into one or more database tables.

The SQL*Loader control file is a text file into which you place a
description of the data to be loaded.
Date file contains the data.

Let Table in which i want to add data be E1 .Control file name be loader.ctl and data file be mydata.csv

loader.ctl ->

load data
into table E1
fields terminated by "," optionally enclosed by '"'
( empno, ename, sal, deptno )

mydata.csv ->
11,'Ann',50000,11
22,'Snow',80000,22
33,'Ash',90000,33
44,'Ronie',30000,44


Using SQL*Plus:

SQL> EDIT loader.ctl

copy and paste your control file, then save it.

SQL> EDIT mydata.csv

copy and paste your data into it, then save it.

SQL> HOST sqlldr scott/tiger control=loader.ctl log=loader.log data=mydata.csv

Notice that there is no space on either side of the equal sign in
"control=loader.ctl". This is a requirement .

To see what happened during the load.

SQL> EDIT loader.log

No comments: