Oracle当然是世界上最强大的数据库,但它的客户端sqlplus真的不友好,现在还不能支持上下方向键翻查历史命令,这里介绍使用readline和rlwrap实现这个功能的方法。
安装readline
[root@localhost yum.repos.d]# yum install readline* Loaded plugins: langpacks, ulninfo Resolving Dependencies --> Running transaction check ---> Package readline.x86_64 0:6.2-10.el7 will be updated ---> Package readline.x86_64 0:6.2-11.el7 will be an update ---> Package readline-devel.x86_64 0:6.2-11.el7 will be installed --> Processing Dependency: ncurses-devel for package: readline-devel-6.2-11.el7.x86_64 --> Running transaction check ---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed --> Finished Dependency Resolution ...
安装rlwrap
在github中下载readline的打包工具(readline wrapper)rlwrap:
wget https://github.com/hanslub42/rlwrap/archive/refs/heads/master.zip
安装相关编译工具并编译:
sudo yum install -y autoconf automake autoreconf --install ./configure make sudo make install $ which rlwrap /usr/local/bin/rlwrap
创建别名
在 oracle用户下的 .bash_profil 中增加两个别名:
alias sqlplus='/usr/local/bin/rlwrap /u01/app/oracle/product/version/db_1/bin/sqlplus' alias rman='/usr/local/bin/rlwrap /u01/app/oracle/product/version/db_1/bin/rman'
这样以后再使用sqlplus和rman的时候就可以使用上下键调出历史命令了!