Solved

Shell script

Posted on 2013-05-21
4
637 Views
Last Modified: 2013-05-23
Hi ,

I have to load data to 50+ tables using sqlloader. I have separate flatfile, control file for each table .first time i ran the sqlloader command manually for each table. But now i want to put all the sqlloder commands in a shell script and run 5 sqlloder commands parallel for 5 different tables. How would i do that.  I appreciate your help
Thank you
0
Comment
Question by:ajaybelde
4 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 39184079
Place the 5 sql loader commands in a single script file and place an '&' after each one.  This runs it in the background.

If you always want them to run no matter what add a nohup in front:

#/bin/ksh
nohup sqlldr control=controlfile1 &
nohup sqlldr control=controlfile2 &
etc...
0
 
LVL 23

Expert Comment

by:David
ID: 39184249
It seems a good solution, but not scalable to say, 50 tables.  After ensuring that the load was scripted to use parallel resources, I might approach using a for loop, as in:

for file in T1 T2 T3 ...T50.; do
nohup $ORACLE_HOME/bin/sqlldr control=control$file &
done

As an aside, remember to adjust your instance resources to optimize the I/O for this batch process.
0
 
LVL 34

Accepted Solution

by:
johnsone earned 250 total points
ID: 39184339
I would do it this way:

#/bin/ksh
sqlldr control=controlfile1 &
sqlldr control=controlfile2 &
sqlldr control=controlfile3 &
sqlldr control=controlfile4 &
sqlldr control=controlfile5 &
wait
sqlldr control=controlfile6 &
sqlldr control=controlfile7 &
sqlldr control=controlfile8 &
sqlldr control=controlfile9 &
sqlldr control=controlfile10 &
wait
....

That will send 5 off and then wait for those to complete before sending off the next 5.  There are ways to do that in a loop, but the commands would have to be pretty similar, or all contained in the control file.  You could loop through every file like this:

#/bin/ksh
wait_cnt=0
for f in *.ctl
do
  sqlldr control=$f &
  let wait_cnt +=1
  if [ $wait_cnt -eq 5 ] ; then
    wait
    wait_cnt=0
  fi
done
wait
0
 
LVL 7

Expert Comment

by:Docteur_Z
ID: 39192085
Thread is closed, but in case...
On system authorizing it, I would use at command with user job queues (queues 'g' to 'z')
echo $COMMAND1 | at - q g -t now
echo $COMMAND2 | at - q h -t now
echo $COMMAND3 | at - q i -t now
echo $COMMAND4 | at - q j -t now
echo $COMMAND5 | at - q k -t now
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

821 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