通过程序得到服务器上面的oracle数据库的版本号

通过程序得到服务器上面的oracle数据库的版本号


 

请问如何通过程序得到远程服务器上面的oracle数据库的版本号??  
  oracle的版本号在哪个文件中描述的?  
 

NO.1   作者: tonyyue0204

执行下面的语句,即可得到所连接数据库的版本号  
  Select   version   FROM   Product_component_version    
  Where   SUBSTR(PRODUCT,1,6)=Oracle;

NO.2   作者: tonyyue0204

dbstart所做的部分是指出你有哪个Oracle版本。它通过检查某些执行文件如sqldba和svrmgrl的存在与否;并用执行文件并使用awk从文件的输出寻找版本号。dbstart脚本不工作的原因是因为下列行:  
  #               Figure   out   if   this   is   a   V5,   V6,   or   V7   database.   Do   we   really   need   V5?  
                          if   [   -f   $ORACLE_HOME/bin/sqldba   ]   ;   then  
                                  VERSION=`$ORACLE_HOME/bin/sqldba   command=exit   |   awk    
                                                  /SQL/*DBA:   (Release|Version)/   {split($3,   V,   ".")   ;  
                                                  print   V[1]}`  
                          else  
                                  if   test   -f   $ORACLE_HOME/bin/svrmgrl;   then  
                                          VERSION=`$ORACLE_HOME/bin/svrmgrl   command=exit   |   awk    
                                                  /PL//SQL   (Release|Version)/   {substr($3,1,3)   ;  
                                                  print   substr($3,1,3)}`  
                                  else  
                                                  VERSION="8.2"  
                                  fi  
                          fi  
           
  (看上去Oracle   8.2好像不再有svrmgrl了)。  
   
  在执行svrmgrl时,它寻找"PL/SQL   Release"   或   "PL/SQL   Version"这样的词句并在这些字后得出版本号。问题是,这两个词都不是svrmgrl的输出部分,如下所示:  
   
  Oracle   Server   Manager   Release   3.1.6.0.0   -   Production  
   
  Copyright   (c)   1997,   1999,   Oracle   Corporation.     All   Rights   Reserved.  
   
  Oracle8i   Enterprise   Edition   Release   8.1.6.1.0   -   Production  
  With   the   Partitioning   option  
  JServer   Release   8.1.6.0.0   -   Production  
   
  SVRMGR>                                    
   
  所以很容易修正它。如果要做的是搜索"Edition   Release",所以可将前面的脚本部分改成如下的样子:  
  #           Figure   out   if   this   is   a   V5,   V6,   or   V7   database.   Do   we   really   need   V5?  
                          if   [   -f   $ORACLE_HOME/bin/sqldba   ]   ;   then  
                                  VERSION=`$ORACLE_HOME/bin/sqldba   command=exit   |   awk    
                                                  /SQL/*DBA:   (Release|Version)/   {split($3,   V,   ".")   ;  
                                                  print   V[1]}`  
                          else  
                                  if   test   -f   $ORACLE_HOME/bin/svrmgrl;   then  
                                          VERSION=`$ORACLE_HOME/bin/svrmgrl   command=exit   |   awk    
                                                  /Edition   Release/   {substr($5,1,3)   ;  
                                                  print   substr($5,1,3)}`  
                                  else  
                                                  VERSION="8.2"  
                                  fi  
                          fi  
   
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值