We should now create a SQL Loader control file by using any text editor. We will use VI editor for this purpose. Remember creating control file is mandatory in SQL Loader. In the control file we specify the format of the input file and target table name and other settings
Login to Linux machine as oracle user and start vi editor by typing the vi command along with control file name. Here we are using orders.ctl you can use any filename as per your choice
$vi orders.ctl
Then write the following contents
LOAD DATA
INFILE '/opt/oracle/test.csv'
BADFILE
'/opt/oracle/test.bad'
DISCARDFILE '/opt/oracle/test.dsc'
APPEND
INTO TABLE SCOTT.Orders
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED
BY '"' TRAILING NULLCOLS
(OrderID,CustomerID,EmployeeID,OrderDate
date "yyyy-mm-dd hh24:mi:ss",
RequiredDate date "yyyy-mm-dd
hh24:mi:ss",ShippedDate date "yyyy-mm-dd hh24:mi:ss",
ShipVia,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry)
After writing the above contents save the file and quit VI by pressing ESC and then :wq
Interface Computers Academy © 2007-2017 All Rights Reserved