【Linux控制台中Oracle的SQL语句不能退格删除】

一、现象描述:
当SQL语句输入错误,想按BackSpace删除键,退格删除,可是偏偏出现令人讨厌的^H符号,
怎么删除也搞不掉,即【SQL> selectt^H^H^H^H^H^H^H】
[root@node1 ~]# su - oracle
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 27 13:29:52 2016
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> desc v$database;
ERROR:
ORA-01034: ORACLE not available

SQL> conn sys/oracle
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory

Warning: You are no longer connected to ORACLE.
SQL> conn sys/oracle as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  2019320 bytes
Variable Size              75497480 bytes
Database Buffers           88080384 bytes
Redo Buffers                2174976 bytes
Database mounted.
Database opened.
SQL> desc v$database
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DBID                                               NUMBER
 NAME                                               VARCHAR2(9)
 CREATED                                            DATE

SQL> ^[[A                  " - rest of line ignored.
SQL> 042: unknown command "

SQL> select * from v$databases;
select * from v$databases
              *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> selectt^H^H^H^H^H^H^H

 

二、解决方案

安装配置readline 和rlwrap包
[root@node1 ~]# cd /home/oracle/
[root@node1 oracle]# ls
database  oraInventory  readline-6.2.tar.gz  rlwrap-0.37.tar.gz

1、安装readline依赖包
[root@node1 oracle]# tar -zxvf readline-6.2.tar.gz
[root@node1 oracle]# cd readline-6.2
[root@node1 readline-6.2]# ./configure
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating examples/Makefile
config.status: creating shlib/Makefile
config.status: creating config.h
config.status: executing default commands
[root@node1 readline-6.2]# make
[root@node1 readline-6.2]# make install
install: you may need to run ldconfig
make[1]: Leaving directory `/home/oracle/readline-6.2/shlib'
[root@node1 readline-6.2]# ldconfig

 

2、安装rlwrap依赖包
[root@node1 oracle]# tar -zxvf rlwrap-0.37.tar.gz
[root@node1 rlwrap-0.37]# ls
aclocal.m4  ChangeLog    configure     doc      Makefile.am  PLEA    test
AUTHORS     completions  configure.ac  filters  Makefile.in  README  TODO
BUGS        config.h.in  COPYING       INSTALL  NEWS         src     tools
[root@node1 rlwrap-0.37]# ./configure
checking for readline in -lreadline... no
configure: error:
You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build
this program!
解决方案:
[root@node1 rlwrap-0.37]# yum install readline*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * updates: mirror.bit.edu.cn
 * addons: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
Setting up Install Process
Parsing package install arguments
Package readline-5.1-3.el5.x86_64 already installed and latest version
Package readline-5.1-3.el5.i386 already installed and latest version
Package readline-devel-5.1-3.el5.x86_64 already installed and latest version
Package readline-devel-5.1-3.el5.i386 already installed and latest version
Nothing to do
[root@node1 rlwrap-0.37]# yum install readline-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * updates: mirror.bit.edu.cn
 * addons: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
Setting up Install Process
Parsing package install arguments
Package readline-devel-5.1-3.el5.x86_64 already installed and latest version
Package readline-devel-5.1-3.el5.i386 already installed and latest version
Nothing to do
[root@node1 rlwrap-0.37]# yum install libtermcap-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * updates: mirror.bit.edu.cn
 * addons: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
Setting up Install Process
Parsing package install arguments
Package libtermcap-devel-2.0.8-46.1.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package libtermcap-devel.x86_64 0:2.0.8-46.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch           Version             Repository    Size
================================================================================
Installing:
 libtermcap-devel         x86_64         2.0.8-46.1          base          56 k

Transaction Summary
================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        

Total download size: 56 k
Is this ok [y/N]: y
Downloading Packages:
libtermcap-devel-2.0.8-46.1.x86_64.rpm                   |  56 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libtermcap-devel                                  [1/1]

Installed: libtermcap-devel.x86_64 0:2.0.8-46.1
Complete!


再次执行,问题解决
[root@node1 rlwrap-0.37]# ./configure
configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands

Now do:
    make (or gmake)  to build rlwrap
    make check       for instructions how to test it
    make install     to install it

[root@node1 rlwrap-0.37]# make && make install
make  install-data-hook
make[3]: Entering directory `/home/oracle/rlwrap-0.37'
chmod a+x /usr/local/share/rlwrap/filters/*
make[3]: Leaving directory `/home/oracle/rlwrap-0.37'
make[2]: Leaving directory `/home/oracle/rlwrap-0.37'
make[1]: Leaving directory `/home/oracle/rlwrap-0.37'

 3、配置环境变量,增加如下内容
[root@node1 rlwrap-0.37]# vi /home/oracle/.bash_profile

# .bash_profile

#add by gaojingsong 20160127
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'

 

三、验证
退出sqlplus控制台,然后重新进入,发现可以退格删除了,还可以上下键翻找以前的命令,至此问题得到圆满解决。
SQL> selectt^H^H^H^H^H^H^H
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
[oracle@node1 ~]$ su - oracle
Password:
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 27 13:48:55 2016

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from dual;

D
-
X

SQL> select * from duaaassss

 

 

你可能感兴趣的:(【Linux控制台中Oracle的SQL语句不能退格删除】)