天天看點

解決sqlplus中輸錯指令時的删除、光标鍵不能使用問題

sqlplus中打錯sql指令時不能回撤,不能修改,隻能回車重新寫,非常麻煩。

看到 一位朋友寫了,我也記錄一下。

出錯如下:[email protected]>aa   ^H^H^[[D^[[D^[[C^[[C^[[A^[[A

第一種方法:使用rlwrap+SQLPLUS方法

1.安裝rlwrap軟體

安裝rlwrap之前需要readline。

readline可以直接在安裝CD光牒中找到 ,也可以自己上傳RMP包到CD光牒進行安裝。

yum -y install readline-devel-5.1-3.el5.i386.rpm

然後安裝rlwrap,需要自己上傳安裝包到 伺服器,進行安裝。

[[email protected] ~]# ls

 rlwrap-0.37.tar.gz

[[email protected] ~]# tar -zxvfrlwrap-0.37.tar.gz

[[email protected] rlwrap-0.37]# pwd

/root/rlwrap-0.37

[[email protected] rlwrap-0.37]# ./configure

[[email protected] rlwrap-0.37]# make

[[email protected] rlwrap-0.37]# make install

2.配置打開SQLPLUS/RMAN等時使用rlwrap

在操作ORACEL的使用者的.bash_profile檔案中增加如下兩句:

[[email protected] oracle]# pwd

/home/oracle

[[email protected] oracle]# cat .bash_profile

……………………

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

配置環境變量參數後使用ORACLE使用者驗證下

[[email protected] ~]$ source .bash_profile

如下報錯是因為我尚未安裝ORACEL,是以沒有SQLPLUST 和RMAN。但是可以看到 輸入sqlplus使用的是rlwrap sqlplus

[[email protected] ~]$ sqlplus

rlwrap: Cannot execute sqlplus: No suchfile or directory

[[email protected] ~]$ rman

rlwrap: Cannot execute rman: No such fileor directory

當然不SOURCE環境變量而重登陸SSH用戶端也是可以的。

方法二:屬于臨時解決方法--本人已驗證,還是建議用上一種安裝rlwrap軟體的方法

臨時的方法:

在console裡輸入stty erase ^H, 然後再使用sqlplus 來連接配接資料庫。此時可以使用删除,但是不能使用上下左右的光标鍵,會亂碼^[[A^[[B^[[B。

[[email protected] ~]$ stty erase ^H

[[email protected] ~]$ sqlplus bys/bys

SQL*Plus: Release 11.2.0.1.0 Production on Mon Nov 4 22:42:37 2013

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[email protected]>aaa  bb^[[D^[[D^[[D^[[D^[[C^[[C^[[A^[[A^[[B^[[B

永久的方式:

在使用者的.bash_profile裡面加入:--同上一步修改環境變量的方法。

stty erase ^H

PUTTY中可以在PUTTY的設定中:

設定——TERMINAL--KEYBOARD --THE Backspace key  選中CONTROL-H

下一篇: sqlplus HELP