部署rlwrap软件

对DBA而言,手动敲命令是家常便饭,本次研究rlwrap,在linux操作系统上,运行SQL*Plu或者RMAN的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重新提交执行.可以大大的提高效率.然而,当在Linux Shell中运行SQL*Plus的时候,系统本身并不提供浏览历史命令行的功能.为了在Linux中达到同样的目的,可以安装rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能.

一、安装readline包(ISO自带)
[root@xuh ~]# yum list|grep readline-devel*
Unable to read consumer identity
readline-devel.i386                         5.1-3.el5                  base     
readline-devel.x86_64                       5.1-3.el5                  base     
[root@xuh ~]# yum install readline-devel* -y
[root@xuh ~]# yum list|grep readline-devel*
Unable to read consumer identity
readline-devel.i386                         5.1-3.el5                  installed
readline-devel.x86_64                       5.1-3.el5                  installed

二、下载rlwrap软件包
http://utopia.knoware.nl/~hlub/uck/rlwrap/
[root@xuh ~]# ls -rtl|grep rlwrap
-rw-r--r-- 1 root root 279608 Aug 21 14:32 rlwrap-0.42.tar.gz

三、安装rlwrap包
[root@xuh ~]# gunzip rlwrap-0.42.tar.gz
[root@xuh ~]# tar -xvf rlwrap-0.42.tar
[root@xuh ~]# cd rlwrap-0.42
[root@xuh rlwrap-0.42]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
.
checking that generated files are newer than configure... done
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands
Now do:
    make (or gmake)  to build rlwrap
    make check       for instructions how to test it
    make install     to install it
[root@xuh rlwrap-0.42]# make
[root@xuh rlwrap-0.42]# make check
[root@xuh rlwrap-0.42]# make install

四、添加环境变量
[oracle@xuh ~]$ vi .bash_profile
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
[oracle@xuh ~]$ source .bash_profile

部署了rlwrap,就可以通过上下键来跳回之前已经执行过的SQL语句,提高效率
请使用浏览器的分享功能分享到微信等