我使用的是Ubuntu 10.04,安裝rlwrap的方式採用的是:sudo apt-get install rlwrap。
使用方式是:rlwrap sqlplus,進入後就可以使用方向鍵了。一種不需要輸入rlwrap的方式是修改自己的bashrc,添加alias sqlplus='rlwrap sqlplus',使其生效後,以後就不再需要輸入rlwrap就可以使用方向鍵了。
當在Linux Shell中運行SQL*Plus的時候,並不提供瀏覽曆史命令列的功能。相反的,在Windows作業系統上,當在DOS命令視窗中運行SQL*Plus的時候,可以使用向上,向下鍵來跳回之前已經執行過的SQL語句。你可以 根據需要修改他們,然後按[Enter]重新提交執行。
為了在Linux中達到同樣的目的,你可以安裝rlwrap,這個程式本身是個Shell,可以運行任何你提供給它的命令包括參數,並添加命令曆史瀏覽功能。 The rlwrap program is under the GPL license。
1:安裝
rlwrap-0.28.tar.gz:http://utopia.knoware.nl/~hlub/uck/rlwrap/
1):解壓縮安裝檔案
[Oracle@Channel-MQ3 ~]$gunzip rlwrap-0.28.tar.gz
[oracle@Channel-MQ3 ~]$tar xvf rlwrap-0.28.tar
2):切換到root使用者,執行下面的命令
[root@Channel-MQ3 ~]# cd /home/oracle/rlwrap-0.28
[root@Channel-MQ3 rlwrap-0.28]# ls
aclocal.m4 completions configure INSTALL README TODO
AUTHORS config.h configure.ac Makefile src tools
bash30-005.patch config.h.in COPYING Makefile.am stamp-h1
BUGS config.log distribution Makefile.in test
ChangeLog config.status doc NEWS test.log
[root@Channel-MQ3 rlwrap-0.28]#./configure
[root@Channel-MQ3 rlwrap-0.28]#make
[root@Channel-MQ3 rlwrap-0.28]#make install
2:使用
$ rlwrap [-options]
[oracle@Channel-MQ3 ~]$ which rlwrap
/usr/local/bin/rlwrap
[oracle@Channel-MQ3 ~]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 18 10:31:11 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from v$sga;
NAME VALUE
-------------------- ----------
Fixed Size 1219856
Variable Size 121635568
Database Buffers 310378496
Redo Buffers 7168000
-- 使用向上鍵調回最後執行的命令,按[Enter]重新執行或修改後按[Enter]執行
SQL> select * from v$sga;
NAME VALUE
-------------------- ----------
Fixed Size 1219856
Variable Size 121635568
Database Buffers 310378496
Redo Buffers 7168000