menu

开发进行时...

crazy coder

Avatar

在Linux下使用SQLPLUS历史回调功能

在Linux中使用SQL*PLUS的时候,并不提供历史回调功能,有时候不太方便。为了能使用向上向下箭调用历史命令,可以安装rlwrap这个软件。
rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能。 The rlwrap program is under the GPL license。
1、安装
rlwrap-0.28.tar.gz下载地址:http://utopia.knoware.nl/~hlub/uck/rlwrap/
1):解压缩安装文件
$gunzip rlwrap-0.28.tar.gz
$tar xvf rlwrap-0.28.tar
2):切换到root用户,执行下面的命令
# cd /home/oracle/rlwrap-0.28
# ls
#./configure
#make
#make install
2、使用
[oracle@localhost ~]$ rlwrap sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Apr 5 10:01:29 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.


SQL> conn / as sysdba
Connected to an idle instance.

然后就可以使用向上、向下键来调用已经执行过的命令了。
如果嫌每次敲rlwrap不爽,可以修改Oracle用户的.bash_profile文件

[oracle@localhost ~]$ vi .bash_profile
加上:
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"

之后就跟直接使用SQL*PLUS没什么区别了,唯一的好处就是多历史回调功能,方便吧,呵呵。
$ sqlplus /nolog


ubuntu下有apt-get install rlwrap


评论已关闭