Oracle數(shù)據(jù)庫中從sql*plus向shell進(jìn)行傳遞變量
作者:佚名
以下的文章主要是對(duì)Oracle數(shù)據(jù)庫中從sql*plus向shell進(jìn)行傳遞變量的實(shí)際操作的介紹,本文是以相關(guān)實(shí)例的方式來對(duì)其進(jìn)行介紹。
Oracle數(shù)據(jù)庫中如何從sql*plus向shell進(jìn)行傳遞變量?在實(shí)際的操作中很多的人都遇到這樣的相關(guān)難題,即,不能使sqlplus向shell傳遞變量,以下我們就來介紹一個(gè)實(shí)例腳本來進(jìn)行折中處理。
- [Oracle@jumper Oracle]$ cat a.sh
- sqlplus -S "/ as sysdba" << !
- set heading off
- col today noprint
- column today new_val dat
- select to_char( sysdate, 'yyyy-mm-dd') today from dual;
- host echo 'today is ' &dat
- exit;
- exit;
- !
- [Oracle@jumper Oracle]$ ./a.sh
- today is 2005-04-11
- [Oracle@jumper Oracle]$
下面我們?cè)賮斫榻B另一個(gè)實(shí)例方法:
- [Oracle@jumper Oracle]$ more a.sh
- #!/bin/ksh
- VALUE=`sqlplus -silent "/ as sysdba" < < END
- set pagesize 0 feedback off verify off heading off echo off
- select max(sequence#) from v\\\$log_history;
- exit;
- END`
- if [ -z "$VALUE" ]; then
- echo "No rows returned from database"
- exit 0
- else
- echo "Max Sequence Number: $VALUE"
- fi
- [Oracle@jumper Oracle]$ ./a.sh
- Max Sequence Number: 17
以上的相關(guān)內(nèi)容就是對(duì)Oracle數(shù)據(jù)庫中怎樣從sql*plus向shell傳遞變量的介紹,望你能有所收獲。
【編輯推薦】
責(zé)任編輯:佚名
來源:
博客園