Hara
December 27, 2006, 1:25am
1
I have 20000 numbers present in a file in each line like
25663,
65465,
74579,
56446,
..
..
I have created a table in db with single number column in it.
create table testhari (no number(9));
I want to insert all these numbers into that table. how can i do it?
can anybody please help..
Please don't suggest to loop 20000 times and connect to db each time using sql plus.. using "while read line do .. done"
andryk
December 27, 2006, 1:51am
2
Whats wrong with the while read line ?!?
Anyway, since you mention sqlplus im guessing you work with oracle database which is good since it has feature designed for that kind of task 'sqlldr'
sqlldr yourdbacctname control=input.ctl log=haritest.log
the content of input.ctl
load data
infile thefilewithno
into table testhari (no)
cskumar
December 27, 2006, 1:52am
3
what database you are using?
use sqlldr.
Eg:
LOAD DATA INFILE * APPEND INTO TABLE <<Tablename>> FIELDS TERMINATED BY "," TRAILING NULLCOLS
(<<fieldname>> INTEGER EXTERNAL)
make it as file.ctl
and then use sqlldr like this
${ORACLE_HOME}/bin/sqlldr userid=${USERPASS} control=<<path>>/file.ctl log=<<path>>/<<filename>>.log data=<<path>>/<<20000filename>> errors=1000 &
Hara
December 27, 2006, 2:19am
4
cskumar:
what database you are using?
use sqlldr.
Eg:
LOAD DATA INFILE * APPEND INTO TABLE <<Tablename>> FIELDS TERMINATED BY "," TRAILING NULLCOLS
(<<fieldname>> INTEGER EXTERNAL)
make it as file.ctl
and then use sqlldr like this
${ORACLE_HOME}/bin/sqlldr userid=${USERPASS} control=<<path>>/file.ctl log=<<path>>/<<filename>>.log data=<<path>>/<<20000filename>> errors=1000 &
Worked pretty good.. thanks a lot Mr.kumar
Sorry, i ve not mentioned my database ie ORACLE.
Problem with while read line is
For me, connecting to db each time is very expensive using sqlplus.. And i can't even imagine it for 20000 times.. Anyways.. thanx a lot for sqlldr option
cskumar
December 27, 2006, 2:35am
5
I also like to share one freeware for loading excel data into oracle.(Oracle 9i+)
Download the exe from http://www.oraxcel.com
As your data is comma separated u can open it excel
and can play with the data.
I hope this might be a very good link.
Regards,
cskumar.