Solved

Shell script

Posted on 2013-05-21
4
622 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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now