Thursday, November 5, 2015

Simple Shell script to execute a sql from UNIX





This is a simple shell script to execute a sql from UNIX shell script.


#!/usr/bin/ksh

export ORACLE_SID=ORCL
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:/usr/local/bin:$PATH
export mydate=`date "+%d%b%Y"`


echo " ************** EXECUTING SQL STARTS HERE ************ "

sqlplus -s USERNAME/PASSWORD@ORCL > /u01/app/oracle/dpump/test.log  <<EOF

SET SERVEROUTPUT ON;
SET FEED OFF;

select name from v\$database;

SET SERVEROUTPUT OFF;
EOF

echo " ************** END OF SQL HERE ************ "

No comments:

Post a Comment