CentOS7 设置oracle sqlplus 命令支持用上下键翻历史命令

# yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
#yum -y install rlwrap
$ yum info rlwrap
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.yun-idc.com
Installed Packages
Name        : rlwrap
Arch        : x86_64
Version     : 0.43
Release     : 1.el7
Size        : 281 k
Repo        : installed
From repo   : epel
Summary     : Wrapper for GNU readline
URL         : https://github.com/hanslub42/rlwrap
License     : GPLv2+
Description : rlwrap is a 'readline wrapper' that uses the GNU readline library to
            : allow the editing of keyboard input for any other command. Input
            : history is remembered across invocations, separately for each command;
            : history completion and search work as in bash and completion word
            : lists can be specified on the command line.
--设置:
# cat /etc/profile.d/oracle.sh 
#/bin/bash
export ORACLE_HOME=/opt/oracle/product/18c/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=ORCLCDB
#alias sqlplus='rlwrap sqlplus / as sysdba'
#alias rman='rlwrap rman target /'
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
#source /etc/profile.d/oracle.sh

注意:使用之后在oracle用户的目录下回隐藏一个文件.sqlplus_history,记录了登录的操作命令。
# su - oracle
$ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .kshrc  .oracle_jre_usage  .sqlplus_history  .viminfo
$ cat .sqlplus_history 
select * from v$version;

exit

 

你可能感兴趣的:(Oracle)