Giriş
sqlplus için bazen ORACLE_HOME ortam değişkenini kullanılıyor. Şöyle yaparız
export ORACLE_BASE=/u02/app/oracle/product/12.2.0 export ORACLE_HOME=$ORACLE_BASE/dbhome_1 export ORACLE_SID=dbz export PATH=$PATH:$ORACLE_HOME/bin
Örnek
Şöyle yaparız
$ sqlplus / as sysdba
Örnek - bash içinden kullanma
Şöyle yaparız.
# set errorcodes SCRIPT_ERROR=1 NO_ERROR=19968 ALREADY_INSTALLED=20000 ALREADY_EXISTS=20001 COMPILATION_ERRORS=20100
Şöyle yaparız. Burada EOF .. EOF ile Bash Here Document kullanılıyor. Aslında gereksiz.
SQLADM="$ORACLE_HOME/bin/sqlplus -S $DBUSER/$DBPASSWORD@\"${DBURL}\" as sysdba"SCRIPTS=`/bin/ls -1`SQL_HEADER="SQL.HEADER"SQL_FOOTER="SQL.FOOTER"for f in $SCRIPTSdocat $SQL_HEADER $f $SQL_FOOTER > $SCRIPT_TO_RUN$SQLADM @$SCRIPT_TO_RUN $f<<EOFEOFERRORCODE=$(( $? + $NO_ERROR ))if [ $ERRORCODE -eq $ALREADY_INSTALLED ]; thenecho "[INFO] Skipped script $f - already installed"echo "[INFO] ------------------------------"continueelif [ $ERRORCODE -eq $ALREADY_EXISTS ]; thenecho "[INFO] Skipped script $f - already exists"echo "[INFO] ------------------------------"continueelif [ $ERRORCODE -eq $COMPILATION_ERRORS ]; thenecho "[ERROR] PL/SQL compilation errors, failed to install $f"echo "[ERROR] ##############################"exit $ERRORCODEelif [ $ERRORCODE -ne $NO_ERROR ]; thenecho "[ERROR] SQL errors, failed to install $f!"echo "[ERROR] ##############################"exit $ERRORCODEelseecho "[INFO] Successfully installed $f"echo "[INFO] ------------------------------"fidone
Hiç yorum yok:
Yorum Gönder