Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading a text file into oracle

Status
Not open for further replies.

sweetleaf

Programmer
Jan 16, 2001
439
CA
Hi,

I have a 30 mb txt file with over 50000 rows that i'd like to insert into a brand new oracle table.
Can anyone tell me the simplest way to do this please?

Any and all help will be greatly appreciated!

 
You need to use the Oracle's SqlLoader utility. Please read the documentation in technet.oracle.com
 
hi vijaychin,

Thanks for your reply. I followed your suggestion and built a .ctl file - but where do i put it? and how do i call it? Is there anything other than calling this .ctl file that needs to be done? is this something that i can do without admin privileges (i am not a DBA).

my .ctl file:

Load Data
infile 'c:\folder1\file1.txt'
fields terminated by "," optionally enclosed by '^'
into table TABLE1(ID,DT,EVENT_DESC,EVENT_AMT,EVENT_CAT)

thanks.
 
That ctl file you wrote require a small change.

put APPEND (or) REPLACE on top of into table.

in the command prompt, go the diretory c:\folder1 and execute the following command.

sqlldr <user>@dbstring/<passwd> control=<yourctl>.ctl log=<logname>.log

if everything is ok with your ctl file, i mean syntax, you will see the count of the records on your screen. Check the log for any errors.

 
Thanks,

Can i run this right from my pc (nt 4.0)? i don't have access to run anything from the unix box that the db is in...

thanks.

 
yes, you can run from wintnt command window. go to your text file directory and try to execute the command. If the command is not recognized, then try to set the path the oracle folder. even if it doesn't work, copy your text file and ctl file to the oracle/bin directory and execute there.
 
ok, i am able to run sqlldr80,

My .ctl file looks like this and reports an &quot;expecting INTO and got &quot;fields terminated by..&quot;
<
Load Data
infile 'bxvu0120020403-2C.txt'
APPEND
into table PPV_MASTERTEXT
(EVENT_ID,EVENT_DT,EVENT_DESC,EVENT_AMT,EVENT_CAT,e1,e2)
fields terminated by &quot;,&quot; optionally enclosed by '^'
>
so i tried
<
Load Data
infile 'bxvu0120020403-2C.txt'
APPEND
into table PPV_MASTERTEXT
fields terminated by &quot;,&quot; optionally enclosed by '^'
(EVENT_ID,EVENT_DT,EVENT_DESC,EVENT_AMT,EVENT_CAT,e1,e2)
>
.. and get &quot;partial record found at eof - but this is misreporting because it still says this even if i rename the filename in the .ctl file to something that does not exist and run it ..

ca you tell me if the syntax looks correct please,
thanks!

 
ok, i am able to run sqlldr80,

My .ctl file looks like this and reports an &quot;expecting INTO and got &quot;fields terminated by..&quot;
<
Load Data
infile 'file.txt'
APPEND
into table table1
(ID,DT,EVENT_DESC,EVENT_AMT,EVENT_CAT,e1,e2)
fields terminated by &quot;,&quot; optionally enclosed by '^'
>
so i tried
<
Load Data
infile 'file1.txt'
APPEND
into table PPV_MASTERTEXT
fields terminated by &quot;,&quot; optionally enclosed by '^'
(ID,DT,EVENT_DESC,EVENT_AMT,EVENT_CAT,e1,e2)
>
.. and get &quot;partial record found at eof - but this is misreporting because it still says this even if i rename the filename in the .ctl file to something that does not exist and run it ..

ca you tell me if the syntax looks correct please,
thanks!

 
some records in your text file may not have values for all the fields.

so, after enclosed by '^' you should give

trailing nullcols

by the way your second syntax is correct, giving the 'fields terminated by' before the field list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top