Note: Technical Talk being moved to:
www.nazimcricket.com/wiki


Wednesday, 31 March 2010

Oracle Shell Script

An example of a shell script which connects to multiple unix hosted databases and runs a simple SQL.
#!/bin/ksh
#
# Shell script that connects to multiple database servers and runs a SQL
#

# Server List
SERVERS='server1 server2 server3'

LOG="/tmp/logfile.log"

> $LOG

for SERVER in $SERVERS
do

sqlplus -s username/password@$SERVER << EOF | tee -a $LOG
select * from global_name;
exit;
EOF

done