在Linux下使用SQLPLUS歷史回撥功能

xyzlotus發表於2008-04-05

在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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12443821/viewspace-228940/,如需轉載,請註明出處,否則將追究法律責任。

相關文章