Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sqlloader

Posted on 2014-09-14
2
Medium Priority
?
209 Views
Last Modified: 2014-10-11
Hi,

My columns is the database table do not map with the csv file,
I would like to move csv data col into oracle data base..

some of the columns in the csv file like ename1 are not exactly the name in the table column(ename)
so how i should go about as i donot want to change ename1, This is a small example which might help me
in resolving the project work... I have done some thing like this
 ename1 =>ename

here is the picec ctl file code, but it is  giving error as
SQL*Loader-350: Syntax error at line 6.
Expecting "," or ")", found "=".
   ( ename1 =>ename,


load data
   infile 'd:\ws\Book1.csv'
   into table emp
   fields terminated by "," optionally enclosed by '"'
   TRAILING nullcols
   ( empno =>empno,
     ename1 =>ename,
	 sal=> sal,
     deptno=>deptno
   )
   into table emp1
   fields terminated by "," optionally enclosed by '"'
   TRAILING nullcols
   ( empno 
     ename
     
   )

Open in new window

0
Comment
Question by:roy_sanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
johnsone earned 1000 total points
ID: 40321809
Columns in a CSV file are not referenced by name.  They don't actually have a name.  They are referenced by position.  The SQL*Loader control file, only contains the database column names.
0
 
LVL 16

Assisted Solution

by:Wasim Akram Shaik
Wasim Akram Shaik earned 1000 total points
ID: 40324724
CSV headers doesn't have to do anything with the actual database table columns, they can be in any name you want,

you just have to map the database columns in the csv file and write the control file in such a way that it loads the database in corresponding columns, you can even skip the header record if you want.. there is a parameter (skip) which when included will skip the header record from the csv file

Sample illustration and syntax can be referred here
http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_skip_header_records_while_loading.3F

in your case you have to do modifications in your control file

this control file which you have posted in your example will do this

skip the header record and loads the data from the csv file named Book1.csv which is present in the location d:\ws into database table emp in the order mentioned below

options(skip=1) 
load data
   infile 'd:\ws\Book1.csv'
   into table emp
   fields terminated by ',' optionally enclosed by '"'
   TRAILING nullcols
   ( empno,
     ename,
     sal,
     deptno
   )

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question