通过程序得到服务器上面的oracle数据库的版本号
请问如何通过程序得到远程服务器上面的oracle数据库的版本号??
oracle的版本号在哪个文件中描述的?
执行下面的语句,即可得到所连接数据库的版本号
Select version FROM Product_component_version
Where SUBSTR(PRODUCT,1,6)=Oracle;
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