我们在使用sqlplus的时候可以通过help或?获得帮助信息,那么这些帮助信息是哪来的呢?
其实sqlplus的帮助信息从是数据库里表(system.help)里获取的。在$ORACLE_HOME/sqlplus/admin/help 目录下的helpus.sql文件里包含的帮助的信息,不过oracle默认带的帮助信息太少,自己可以通过其它途径获取更全的帮助脚本。那么我们自己如何来安装帮助呢?下面以系统自带的脚本为例来演示安装过程。
所有用的sql脚本都保存在 $ORACLE_HOME/sqlplus/admin/help 目录下,包含了四个文件:helpbld.sql helpdrop.sql helpus.sql hlpbld.sql,第一个helpbld.sql实际是调用第四个脚本hlpbld.sql来进行安装的,helpdrop.sql是删除help表和HELP_TEMP_VIEW视图的脚本,helpus.sql是安装的帮助信息。如果自己找到其它更全的脚本也放到这个目录下,便于管理。
因为help表是存在于oracle数据库里的,所以我们要保证oracle数据库已经启动,而且安装了sqlplus。之后以system身份登录在执行安装脚本helpbld.sql或hlpbld.sql均可。我们在执行脚本的时候需要输入两个参数
SQL> @ ?/sqlplus/admin/help/helpbld.sql
Enter value for 1: $ORACLE_HOME/sqlplus/admin/help
Enter value for 2: $ORACLE_HOME/sqlplus/admin/help/helpus.sql
Enter value for 1: $ORACLE_HOME/sqlplus/admin/help
Enter value for 2: $ORACLE_HOME/sqlplus/admin/help/helpus.sql
Enter value for 1: 帮助系统脚本所在目录
Enter value for 2: 帮助系统内容脚本
运行后sqlplus的help帮助系统就装好了。
也可以用另外方法安装,设置环境变量
SYSTEM_PASS=SYSTEM/password
EXPORT SYSTEM_PASS
然后运行$ORACLE_HOME/bin/helpins脚本也实现安装。
其实上面所有的安装过程都可以通过helpins脚本分析得到。内容如下可以读一遍自然晓得其中奥秘。
附录:
[oracle@rhel5 bin]$ cat helpins
:
#
# Copyright (c) 1988, 2003, Oracle Corporation. All rights reserved.
#
# NAME
# helpins
#
# DESCRIPTION
# Script. to install the SQL*Plus HELP system
#
# USAGE
# If you want to load the English language data file ("helpus.sql"),
# and the SYSTEM schema's password is "manager" then execute these
# commands at the operating system prompt:
#
# ./helpins system manager us
#
# This assumes you have set your default environment (e.g
# ORACLE_HOME, ORACLE_SID) to connect to the correct database.
#
# The first argument should always be SYSTEM
#
# The third argument to this script. specifies the language for the
# HELP system. The available language files are in
# $ORACLE_HOME/admin/help.
:
#
# Copyright (c) 1988, 2003, Oracle Corporation. All rights reserved.
#
# NAME
# helpins
#
# DESCRIPTION
# Script. to install the SQL*Plus HELP system
#
# USAGE
# If you want to load the English language data file ("helpus.sql"),
# and the SYSTEM schema's password is "manager" then execute these
# commands at the operating system prompt:
#
# ./helpins system manager us
#
# This assumes you have set your default environment (e.g
# ORACLE_HOME, ORACLE_SID) to connect to the correct database.
#
# The first argument should always be SYSTEM
#
# The third argument to this script. specifies the language for the
# HELP system. The available language files are in
# $ORACLE_HOME/admin/help.
# Display abort message on interupt
trap 'echo "^G^G Help installation aborted."; exit' 1 2 3 15
# Check to make sure that required variables are set.
# If they are not, prompt user to set them and restart install
# If they are not, prompt user to set them and restart install
case $ORACLE_HOME in
"") echo "ORACLE_HOME not set."
echo "Set and export ORACLE_HOME, then restart help installation."
exit 1 ;;
esac
"") echo "ORACLE_HOME not set."
echo "Set and export ORACLE_HOME, then restart help installation."
exit 1 ;;
esac
if [ $# -eq 0 ]; then
case $SYSTEM_PASS in
"") echo "SYSTEM_PASS environment variable not set."
echo "Installing HELP into the SYSTEM schema"
PASSWD=""
while [ -z "$PASSWD" ]
do
echo "Enter SYSTEM passwd: "
read PASSWD
done
SYSTEM_PASS="system/$PASSWD";;
esac
"") echo "SYSTEM_PASS environment variable not set."
echo "Installing HELP into the SYSTEM schema"
PASSWD=""
while [ -z "$PASSWD" ]
do
echo "Enter SYSTEM passwd: "
read PASSWD
done
SYSTEM_PASS="system/$PASSWD";;
esac
HELPLANG="us"
elif [ $# -eq 3 ]; then
SYSTEM_PASS="$1"/"$2";
export SYSTEM_PASS
HELPLANG="$3"
export SYSTEM_PASS
HELPLANG="$3"
else
echo "Usage: $0 system <system_password> <language>" >&1
exit 1
exit 1
fi
# Default to US if we can't find the specified language file
HELPDIR=$ORACLE_HOME/sqlplus/admin/help
HELPFILE=$HELPDIR/helpbld.sql
HELPDATA=$HELPDIR/help${HELPLANG}.sql
HELPFILE=$HELPDIR/helpbld.sql
HELPDATA=$HELPDIR/help${HELPLANG}.sql
[ ! -f "$HELPDATA" ] &&
{ echo "Help file $HELPDATA not found"
HELPDATA=$HELPDIR/helpus.sql;
echo "Using $HELPDATA"
}
{ echo "Help file $HELPDATA not found"
HELPDATA=$HELPDIR/helpus.sql;
echo "Using $HELPDATA"
}
[ ! -f "$HELPDATA" ] &&
{ echo "Help file $HELPDATA not found"
exit 1 ; }
{ echo "Help file $HELPDATA not found"
exit 1 ; }
#
# Load the HELP system
#
# Load the HELP system
#
$ORACLE_HOME/bin/sqlplus "$SYSTEM_PASS" @"$HELPFILE" "$HELPDIR" "$HELPDATA"
exit $?