Migrate MySQL to Oracle - Tutorial Step 4

Step 4

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) 

write control file for sql loader 

After writing the above contents save the file and quit VI by pressing ESC and then :wq

next step

New: Modern Oracle

Concepts here also apply to Oracle 19c/21c/23ai unless a version note says otherwise. See the homepage for what's changed.