使用rlwrap上下翻sqlplus历史命令
2012-12-19 11:43
417 查看
在Linux的sqlplus中运行SQL语句之后,想用上下键把历史命令找出来,这样是linux系统默认是不支持的。
如何像windows里的cmd窗口的sqlplus一样能上下翻历史命令呢?
可以使用rlwrap工具实现这个功能
1.下载rlwrap工具
http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz
2.安装rlwrap
[root@server122 oracle]# tar -zxvf rlwrap-0.37.tar.gz
[root@server122 rlwrap-0.37]# ./configure
[root@server122 rlwrap-0.37]# make
[root@server122 rlwrap-0.37]# make install
--查看rlwrap命令
[root@server122 rlwrap-0.37]# rlwrap
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b <chars> --break-chars=<chars>
-c --complete-filenames
-C <name|N> --command-name=<name|N>
-D <0|1|2> --history-no-dupes=<0|1|2>
-f <completion list> --file=<completion list>
-g <regexp> --forget-matching=<regexp>
-h --help
-H <file> --history-filename=<file>
-i --case-insensitive
-I --pass-sigint-as-sigterm
-l <file> --logfile=<file>
-n --no-warnings
-N --no-children
-o --one-shot
-O <regexp> --only-cook=<regexp>
-p[colour] --prompt-colour[=colour]
-P <input> --pre-given=<input>
-q <chars> --quote-characters=<chars>
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-R --renice
-v --version
-s <N> --histsize=<N> (negative: readonly)
-S <prompt> --substitute-prompt=<prompt>
-t <name> --set-term-name=<name>
-w <N> --wait-before-prompt=<N> (msec, <0 : patient mode)
-z <filter command> --filter=<filter command>
bug reports, suggestions, updates: http://utopia.knoware.nl/~hlub/uck/rlwrap/
3.使用rlwrap
[oracle@server122 ~]$ rlwrap sqlplus "/as sysdba"
SQL> show sga
Total System Global Area 2.5770E+10 bytes
Fixed Size 2142928 bytes
Variable Size 2852130096 bytes
Database Buffers 2.2901E+10 bytes
Redo Buffers 14630912 bytes
--此时用上下键功能可以就可像windows里一样,可以上下翻命令了
SQL> show sga
4.设置sqlplus别名
为了sqlplus使用方便,让sqlplus默认在rlwrap方式下运行,可以设置一个别名
[oracle@server122 ~]$ pwd
/home/oracle
[oracle@server122 ~]$ vi .bash_profile
alias sqlplus='rlwrap sqlplus' #添加此内容
--使之生效,或是重新登录oracle用户
[oracle@server122 ~]$ source .bash_profile
--用type sqlplus验证,如果显示下面的信息证明alias设置成功
[oracle@server122 ~]$ type sqlplus
sqlplus is aliased to `rlwrap sqlplus'
[oracle@server122 ~]$ sqlplus "/as sysdba"
SQL> show sga
Total System Global Area 2.5770E+10 bytes
Fixed Size 2142928 bytes
Variable Size 2852130096 bytes
Database Buffers 2.2901E+10 bytes
Redo Buffers 14630912 bytes
--同样上下翻可以再显历史命令
SQL> show sga
注意:
alias定义中使用的是单引号,而不是TAB上面的那个,/home/oracle/是oracle用户的主目录。
问题:
在安装rlwrap时,如报下面的错误:
[root@nticket1 rlwrap-0.37]# ./configure
......
OPENPTY
configure: checking for pty ranges...
checking for tgetent... no
checking for tgetent in -lcurses... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
configure: WARNING: No termcap nor curses library found
checking for readline in -lreadline... no
configure: error:
You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build
this program!
解决方法
安装下面包
libtermcap-devel
readline-5.1-1.1
readline-devel-5.1-1.1
如何像windows里的cmd窗口的sqlplus一样能上下翻历史命令呢?
可以使用rlwrap工具实现这个功能
1.下载rlwrap工具
http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz
2.安装rlwrap
[root@server122 oracle]# tar -zxvf rlwrap-0.37.tar.gz
[root@server122 rlwrap-0.37]# ./configure
[root@server122 rlwrap-0.37]# make
[root@server122 rlwrap-0.37]# make install
--查看rlwrap命令
[root@server122 rlwrap-0.37]# rlwrap
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b <chars> --break-chars=<chars>
-c --complete-filenames
-C <name|N> --command-name=<name|N>
-D <0|1|2> --history-no-dupes=<0|1|2>
-f <completion list> --file=<completion list>
-g <regexp> --forget-matching=<regexp>
-h --help
-H <file> --history-filename=<file>
-i --case-insensitive
-I --pass-sigint-as-sigterm
-l <file> --logfile=<file>
-n --no-warnings
-N --no-children
-o --one-shot
-O <regexp> --only-cook=<regexp>
-p[colour] --prompt-colour[=colour]
-P <input> --pre-given=<input>
-q <chars> --quote-characters=<chars>
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-R --renice
-v --version
-s <N> --histsize=<N> (negative: readonly)
-S <prompt> --substitute-prompt=<prompt>
-t <name> --set-term-name=<name>
-w <N> --wait-before-prompt=<N> (msec, <0 : patient mode)
-z <filter command> --filter=<filter command>
bug reports, suggestions, updates: http://utopia.knoware.nl/~hlub/uck/rlwrap/
3.使用rlwrap
[oracle@server122 ~]$ rlwrap sqlplus "/as sysdba"
SQL> show sga
Total System Global Area 2.5770E+10 bytes
Fixed Size 2142928 bytes
Variable Size 2852130096 bytes
Database Buffers 2.2901E+10 bytes
Redo Buffers 14630912 bytes
--此时用上下键功能可以就可像windows里一样,可以上下翻命令了
SQL> show sga
4.设置sqlplus别名
为了sqlplus使用方便,让sqlplus默认在rlwrap方式下运行,可以设置一个别名
[oracle@server122 ~]$ pwd
/home/oracle
[oracle@server122 ~]$ vi .bash_profile
alias sqlplus='rlwrap sqlplus' #添加此内容
--使之生效,或是重新登录oracle用户
[oracle@server122 ~]$ source .bash_profile
--用type sqlplus验证,如果显示下面的信息证明alias设置成功
[oracle@server122 ~]$ type sqlplus
sqlplus is aliased to `rlwrap sqlplus'
[oracle@server122 ~]$ sqlplus "/as sysdba"
SQL> show sga
Total System Global Area 2.5770E+10 bytes
Fixed Size 2142928 bytes
Variable Size 2852130096 bytes
Database Buffers 2.2901E+10 bytes
Redo Buffers 14630912 bytes
--同样上下翻可以再显历史命令
SQL> show sga
注意:
alias定义中使用的是单引号,而不是TAB上面的那个,/home/oracle/是oracle用户的主目录。
问题:
在安装rlwrap时,如报下面的错误:
[root@nticket1 rlwrap-0.37]# ./configure
......
OPENPTY
configure: checking for pty ranges...
checking for tgetent... no
checking for tgetent in -lcurses... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
configure: WARNING: No termcap nor curses library found
checking for readline in -lreadline... no
configure: error:
You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build
this program!
解决方法
安装下面包
libtermcap-devel
readline-5.1-1.1
readline-devel-5.1-1.1
相关文章推荐
- SQL*plus中,使用上下键,调出历史命令
- Linux中SQLPLUS上下键不能显示历史命令的问题/输入错误不能回退问题 rlwrap解决
- 使用rlwrap调用sqlplus中历史命令
- Linux环境下的SQL*PLUS及RMAN中不能使用上下方向键查看命令历史的解决方法
- linux下使用rlwrap调用sqlplus中历史命令
- 安装rlwrap, 使用rlwrap调用sqlplus中历史命令
- linux 中上下键跳SQL命令 rlwrap使用方法
- linux 中上下键跳SQL命令 rlwrap使用方法
- 使用rlwrap实现sqlplus上下键翻阅输过的oracle历史命令
- 安装rlwrap解决oracle sqlplus命令行下找回历史命令,以及回退键,方向键不好使的问题
- Linux 下 SQL*Plus 上下键不能查看历史命令
- Linux 下如何 sql*plus 实现上下键历史记录显示(安装rlwrap 以及 readline)
- rlwrap linux sqlplus 调用历史命令
- oracle sqlplus+rlwrap-实现查看历史命令的操作
- Linux中SQLplus上下键不能显示历史命令的问题
- Linux中SQLplus上下键不能显示历史命令的问题
- 在linux的SQL*Plus下用上下键翻历史命令
- rlwrap 实现键盘上下箭头,调出历史执行的SQL命令
- rlwrap 的安装使用(实现sqlplus下命令行history编辑)
- Linux中SQLplus上下键不能显示历史命令的问题