linux中安装rlwrap后,在数据库中我们可以使用退格键删除前一个字符。使用上下键查看之前的命令

通常当在linux中安装完oracle数据库后,sqlplus / as sysdba编辑sql语句时,通常会遇到如下现象,操作极其不方便:

输入错误需要删除,按删除键后:
SQL> select * from v#^H^H^H^H;

使用上查看之前输入的命令,会出现:
SQL> ^[[A^[[A^[[A^[[A^[[A

通过安装rlwrap,可以完美解决这个问题:

下载地址:https://pan.baidu.com/s/1TKWzWjzfH8dvW9xlWBSRxw       

密码:1vtq

 

rlwrap安装时候要先编译,编辑前在验证时候会报错提示缺少包,安装下面3个即可
libtermcap-devel , readline , readline-devel

我是在虚拟机里面安装,虚拟机可以上外网,就用yum安装了。

[root@node2 db_1]# yum install -y readline*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
.......

[root@node2 db_1]# yum install -y libtermcap-devel*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
.......

 

解压,编译,安装:

[root@node1 packages]# tar -zxvf rlwrap-0.37.tar.gz 
rlwrap-0.37/
rlwrap-0.37/completions/
rlwrap-0.37/completions/testclient
......


[root@node1 packages]# cd rlwrap-0.37/
[root@node1 rlwrap-0.37]# ./configure 
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
......
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  all-recursive
make[1]: 进入目录“/packages/rlwrap-0.37”
Making all in doc
......

 

修改环境变量:

[root@node1 rlwrap-0.37]# su - oracle
上一次登录:二 4月 13 14:59:43 CST 2021pts/2 上
node1-> id
uid=2101(oracle) gid=2000(oinstall) groups=2000(oinstall),2201(asmdba),2300(dba),2301(oper)
node1-> pwd
/home/oracle
node1-> vi .bash_profile 

在环境变量中添加如下内容:

alias sqlplus='rlwrap sqlplus / as sysdba'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'

添加后如下图:

 

source命令使环境变量生效:

node1-> source .bash_profile 

 

直接输入sqlplus命令就可以了

[root@node1 rlwrap-0.37]# su - oracle
上一次登录:二 4月 13 16:26:43 CST 2021pts/0 上
node1-> sqlplus

SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 13 16:35:12 2021

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>

posted @ 2021-04-13 16:36  飞鸽子  阅读(183)  评论(0编辑  收藏  举报