-1

This is just an effort to share a solution that we used in our organisation for the benefit of all.

Aim: We have a file MYFILE.CSV. We need to create a table in Oracle database and load this file into that table.

ArtBajji
  • 949
  • 6
  • 14

1 Answers1

0
create table BLOBTABLE(FILENAME blob);

Create a text file, MYDATA.TXT with the text MYFILE.CSV.

Control File: MYDATA.CTL

load data
infile MYDATA.TXT
truncate into BLOBTABLE
fields terminated by ‘,’ trailing nullcols
(
input_file filler,
FILENAME lobfile(input_file)
terminated by eof 
)

Place all the three files, MYFILE.CSV, MYDATA.CTL and MYDATA.TXT in a folder. In command prompt, change directory to that folder and type the below command.

sqlldr userid=user/pwd@sid control=mydata.ctl log=mydata.log bad=mydata.bad

Hit ENTER!!!

ArtBajji
  • 949
  • 6
  • 14
  • Well, that won't work. You forgot the TABLE keyword in the APPEND line. Single quotes are invalid (look kind of *fancy*, ASCII 145; should be ASCII 39). Also, I'd say that something like that belongs to your BLOG, not Stack Overflow. Other than that, yes - it's OK. – Littlefoot Mar 12 '18 at 08:57
  • @Littlefoot: You are right with respect to the table clause. We used truncate and not append as we did not need the old data after new load. I have change it now. Single quotes are valid and it works. Also technical solutions like these are much relevant in Stack Overflow and will be helpful to others. https://oracle-base.com/articles/10g/load-lob-data-using-sql-loader – ArtBajji Mar 14 '18 at 07:19