linux 下sqlplus裏沒法使用方向鍵的解決


rlwrap 的安裝使用 sql

 

在Windows操做系統上,當在DOS命令窗口中運行SQL*Plus的時候,能夠使用向上,向下鍵來跳回以前已經執行過的SQL語句.你能夠根據須要修改他們,而後按Enter鍵從新提交執行.
然而,當在Linux Shell中運行SQL*Plus的時候,並不提供瀏覽歷史命令行的功能.
爲了在Linux中達到一樣的目的,你能夠安裝rlwrap,這個程式自己是個Shell,能夠運行任何你提供給它的命令包括參數,並添加命令歷史瀏覽功能.The rlwrap program is under the GPL license.


一:安裝readline
OS的安裝光盤裏提供了readline包.
[root@oracle11g ~]# rpm -Uvh libtermcap-devel-2.0.8-46.1.i386.rpm
[root@oracle11g ~]# rpm -Uvh readline*
package readline-5.1-1.1 is already installed
[root@oracle11g ~]# rpm -Uvh readline-devel-5.1-1.1.i386.rpm

二:安裝rlwrap
Download:
[root@oracle11g ~]# tar -zxvf rlwrap-0.30.tar.gz
[root@oracle11g ~]# cd rlwrap-0.30
[root@oracle11g rlwrap-0.30]# ./configure
[root@oracle11g rlwrap-0.30]# make
[root@oracle11g rlwrap-0.30]# make install
[root@oracle11g rlwrap-0.30]# rlwrap
Usage: rlwrap [options] command ...

Options:
   -a[password:]              --always-readline[=password:]
   -A                      --ansi-colour-aware
   -b <chars>                 --break-chars=<chars>
   -c                      --complete-filenames
   -C <name|N>             --command-name=<name|N>
   -D <0|1|2>                 --history-no-dupes=<0|1|2>
   -f <completion list>    --file=<completion list>
   -F <format string>       --history-format=<format string>
   -h                      --help
   -H <file>                --history-filename=<file>
   -i                      --case-insensitive
   -l <file>                --logfile=<file>
   -n                      --no-warnings
   -p[ANSI colour spec]    --prompt-colour[=ANSI colour spec]
   -P <input>                 --pre-given=<input>
   -q <chars>                 --quote-characters=<chars>
   -m[newline substitute]     --multi-line[=newline substitute]
   -r                      --remember
   -v                      --version
   -s <N>                   --histsize=<N> (negative: readonly)
   -t <name>                --set-term-name=<name>

bug reports, suggestions, updates:

[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile
添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias定義中使用的是單引號,而不是TAB上面的那個。

三:使用rlwrap
[oracle@oracle11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Jul 29 21:28:30 2008

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$sga;

NAME                   VALUE
-------------------- ----------
Fixed Size              1299116
Variable Size       155192660
Database Buffers    79691776
Redo Buffers          2347008

使用向上鍵調回最後執行的命令,按Enter鍵從新執行或修改後按Enter鍵執行.
SQL> select * from v$sga;

NAME                   VALUE
-------------------- ----------
Fixed Size              1299116
Variable Size       155192660
Database Buffers    79691776
Redo Buffers          2347008

SQL> 



Note:
解決在sqlplus下輸錯命令後正常刪除的方法
[oracle@oracle11g ~]$ vi /home/oracle/.bash_profile
添加
stty erase ^h bash

相關文章
相關標籤/搜索