I. yum方式安装
CentOS系统默认的yum软件仓库中没有rlwrap这个包,需要通过第三方yum源安装。
a. 安装第三方yum源
# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 //导入key
默认会在/etc/yum.repos.d/下创建epel.repo和epel-testing.repo两个配置文件。
b. 安装rlwrap和readline
# yum install rlwrap readline readline-devel
II. 源码包安装
其他Linux发行版如果源里没有rlwrap和readline的(如SUSE企业版默认没有这两个包),要分别下载这两个源码包编译安装一下。
a. 安装readline
# wget ftp://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz
# tar zxvf readline-6.2.tar.gz
# cd readline-6.2/
# ./configure
# make
# make install
b. 安装rlwrap
# wget http://utopia.knoware.nl/~hlub/rlwrap/rlwrap-0.37.tar.gz
# tar zxvf rlwrap-0.37.tar.gz
# cd rlwrap-0.37/
# ./configure
# make
# make install
在Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重新提交执行. 然而,当在Linux Shell中运行SQL*Plus的时候,并不提供浏览历史命令行的功能. 为了在Linux中达到同样的目的,你可以安装rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能.The rlwrap program is under the GPL license.
一:安装readline
OS的安装光盘里提供了readline包(在安装包的centos/rpms目录下,有两个以readline开头的包).
[root@oracle11g ~]# rpm -Uvh readline*
error: Failed dependencies: libtermcap-devel is needed by readline-devel-5.1-1.1.i386.rpm
[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:http://utopia.knoware.nl/~hlub/uck/rlwrap/
[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
或者直接可以:yum install rlwrap readline readline-devel
[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile(该文件 在你所安装的oracle目录下可找到)alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
但用这样的注释,在每次logout 后,都要每次执行 source ./.bash_profile才会生效
最方便的是在.bashrc文件中添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
接着执行source ./bashrc这样即使注销也不会失效
[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>
Notes:
解决在sqlplus下输错命令后正常删除的方法
[oracle@oracle11g ~]$ vi /home/oracle/.bash_profile
添加stty erase ^h