为了linux下的sqlplus方便调用历史命令和退格,安装下rlwrap,最新版本是0.43,貌似作者已经不更新了
下载地址 https://fossies.org/linux/privat/rlwrap-0.42.tar.gz/
下载后winscp传入到linux上,然后安装
[root@localhost db]#ll|grep rlwrap -rw-r--r--. 1 root root 313139 Jul 30 08:50 rlwrap-0.43.tar.gz [root@localhost db]#tar -xzf rlwrap-0.43.tar.gz [root@localhost db]#mv rlwrap-0.43 /usr/local/rlwrap [root@localhost db]#cd /usr/local/rlwrap/ [root@localhost rlwrap]#./configure -q configure: WARNING: No termcap nor curses library found configure: error: You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build this program! [root@localhost rlwrap]#yum -yq install readline* Loaded plugins: langpacks, ulninfo Ignored option -q, -v, -d or -e (probably due to merging: -yq != -y -q) Package readline-6.2-10.el7.x86_64 already installed and latest version Resolving Dependencies (many more lines suppressed) Installed: readline-devel.x86_64 0:6.2-10.el7 Dependency Installed: ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 Complete! [root@localhost rlwrap]#./configure -q Will rlwrap find command's working directory under /proc/< commands pid>/cwd? let's see... Now do: make (or gmake) to build rlwrap make check for instructions how to test it make install to install it [root@localhost rlwrap]#make && make install make all-recursive make[1]: Entering directory `/usr/local/rlwrap' Making all in doc make[2]: Entering directory `/usr/local/rlwrap/doc' sed -e 's#@DATADIR@#/usr/local/share#' rlwrap.man > rlwrap.1 make[2]: Leaving directory `/usr/local/rlwrap/doc' Making all in src make[2]: Entering directory `/usr/local/rlwrap/src' gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c mv -f .deps/main.Tpo .deps/main.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT signals.o -MD -MP -MF .deps/signals.Tpo -c -o signals.o signals.c mv -f .deps/signals.Tpo .deps/signals.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT readline.o -MD -MP -MF .deps/readline.Tpo -c -o readline.o readline.c mv -f .deps/readline.Tpo .deps/readline.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT pty.o -MD -MP -MF .deps/pty.Tpo -c -o pty.o pty.c mv -f .deps/pty.Tpo .deps/pty.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT completion.o -MD -MP -MF .deps/completion.Tpo -c -o completion.o completion.c mv -f .deps/completion.Tpo .deps/completion.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT term.o -MD -MP -MF .deps/term.Tpo -c -o term.o term.c mv -f .deps/term.Tpo .deps/term.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT ptytty.o -MD -MP -MF .deps/ptytty.Tpo -c -o ptytty.o ptytty.c mv -f .deps/ptytty.Tpo .deps/ptytty.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT utils.o -MD -MP -MF .deps/utils.Tpo -c -o utils.o utils.c mv -f .deps/utils.Tpo .deps/utils.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c mv -f .deps/string_utils.Tpo .deps/string_utils.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT malloc_debug.o -MD -MP -MF .deps/malloc_debug.Tpo -c -o malloc_debug.o malloc_debug.c mv -f .deps/malloc_debug.Tpo .deps/malloc_debug.Po gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT filter.o -MD -MP -MF .deps/filter.Tpo -c -o filter.o filter.c mv -f .deps/filter.Tpo .deps/filter.Po gcc -DDATADIR=\"/usr/local/share\" -g -O2 -o rlwrap main.o signals.o readline.o pty.o completion.o term.o ptytty.o utils.o string_utils.o malloc_debug.o filter.o -lutil -lreadline -ltinfo make[2]: Leaving directory `/usr/local/rlwrap/src' Making all in filters make[2]: Entering directory `/usr/local/rlwrap/filters' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/usr/local/rlwrap/filters' make[2]: Entering directory `/usr/local/rlwrap' make[2]: Leaving directory `/usr/local/rlwrap' make[1]: Leaving directory `/usr/local/rlwrap' Making install in doc make[1]: Entering directory `/usr/local/rlwrap/doc' make[2]: Entering directory `/usr/local/rlwrap/doc' make[2]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/share/man/man1' /usr/bin/install -c -m 644 rlwrap.1 '/usr/local/share/man/man1' make[2]: Leaving directory `/usr/local/rlwrap/doc' make[1]: Leaving directory `/usr/local/rlwrap/doc' Making install in src make[1]: Entering directory `/usr/local/rlwrap/src' make[2]: Entering directory `/usr/local/rlwrap/src' /usr/bin/mkdir -p '/usr/local/bin' /usr/bin/install -c rlwrap '/usr/local/bin' make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/usr/local/rlwrap/src' make[1]: Leaving directory `/usr/local/rlwrap/src' Making install in filters make[1]: Entering directory `/usr/local/rlwrap/filters' make[2]: Entering directory `/usr/local/rlwrap/filters' make[2]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/share/man/man3' /usr/bin/install -c -m 644 RlwrapFilter.3pm '/usr/local/share/man/man3' make[2]: Leaving directory `/usr/local/rlwrap/filters' make[1]: Leaving directory `/usr/local/rlwrap/filters' make[1]: Entering directory `/usr/local/rlwrap' make[2]: Entering directory `/usr/local/rlwrap' make[2]: Nothing to be done for `install-exec-am'. /usr/bin/mkdir -p '/usr/local/share/rlwrap' /usr/bin/mkdir -p '/usr/local/share/rlwrap/filters' /usr/bin/install -c -m 644 filters/README filters/RlwrapFilter.pm filters/RlwrapFilter.3pm filters/count_in_prompt filters/pipeto filters/logger filters/null filters/unbackspace filters/pipeline filters/ftp_filter filters/handle_hotkeys filters/history_format filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing filters/paint_prompt.py filters/handle_hotkeys.py filters/logger.py filters/pipeto.py filters/rlwrapfilter.py filters/null.py filters/censor_passwords.py filters/count_in_prompt.py filters/ftp_filter.py '/usr/local/share/rlwrap/filters' /usr/bin/mkdir -p '/usr/local/share/rlwrap/completions' /usr/bin/install -c -m 644 completions/testclient completions/coqtop '/usr/local/share/rlwrap/completions' make install-data-hook make[3]: Entering directory `/usr/local/rlwrap' chmod a+x /usr/local/share/rlwrap/filters/* make[3]: Leaving directory `/usr/local/rlwrap' make[2]: Leaving directory `/usr/local/rlwrap' make[1]: Leaving directory `/usr/local/rlwrap' [root@localhost rlwrap]#
添加一条别名sql到oracle用户的环境变量中并使之生效,测试后上下左右键在sqlplus中均良好使用,提升了一大截sqlplus中的代码体验
[oracle@localhost ~]$ cat .bashrc|grep sql alias sql='rlwrap sqlplus / as sysdba' [oracle@localhost ~]$ . .bashrc [oracle@localhost ~]$ sql SQL*Plus: Release 11.2.0.1.0 Production on Tue Jul 30 09:41:05 2019 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 09:41:05 SYS@study> select 1 from dual; 1 ---------- 1 Elapsed: 00:00:00.00 09:41:11 SYS@study> select 1 from dual;