您的位置:首页 > 数据库

SQL*plus中,使用上下键,调出历史命令

2011-11-12 15:54 337 查看
在RHEL5.5上安装了Oracle10g,使用sql*plus时,由于自己对oracle不太熟悉,经常性输错命令,很长的一句,在一个个的打出来,太浪费时间了。有没有可以像linux一样,上下键可以调出历史命令那?网上搜了下,还真有这样的软件。

这就是rlwrap。

1、下载地址:http://utopia.knoware.nl/~hlub/rlwrap/ ,现在是rlwrap-0.37.tar.gz版本(点击直接下载)。

安装吧……

2、我用的SecureCRT,用自带的zmodem来传输这个才245K的文件。步骤如下:

SecureCRT里面有个transfer菜单,你选择Zmodem upload list ... ,然后选择你要上传的文件,选完之后点击OK。再Linux命令行中cd到你想保存这个文件的目录下,然后点击transfer菜单的Start zmodem upload,在你cd的这个目录中,就出现这个文件了。

3、安装rlwrap

先解压缩

[root@oral ~]# tar -zxvf rlwrap-0.37.tar.gz

[root@oral ~]# cd rlwrap-0.37

安装

[root@oral rlwrap-0.37]# ./configure

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking whether make sets $(MAKE)... (cached) yes

checking whether build environment is sane... yes

checking for style of include used by make... GNU

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

……

[root@oral rlwrap-0.37]# make

make all-recursive

make[1]: Entering directory `/root/rlwrap-0.37'

Making all in doc

make[2]: Entering directory `/root/rlwrap-0.37/doc'

sed -e 's#@DATADIR@#/usr/local/share#' rlwrap.man > rlwrap.1

make[2]: Leaving directory `/root/rlwrap-0.37/doc'

Making all in src

make[2]: Entering directory `/root/rlwrap-0.37/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

……

[root@oral rlwrap-0.37]# make install

Making install in doc

make[1]: Entering directory `/root/rlwrap-0.37/doc'

make[2]: Entering directory `/root/rlwrap-0.37/doc'

make[2]: Nothing to be done for `install-exec-am'.

test -z "/usr/local/share/man/man1" || /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 `/root/rlwrap-0.37/doc'

make[1]: Leaving directory `/root/rlwrap-0.37/doc'

Making install in src

make[1]: Entering directory `/root/rlwrap-0.37/src'

make[2]: Entering directory `/root/rlwrap-0.37/src'

test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"

/usr/bin/install -c rlwrap '/usr/local/bin'

……

[root@oral 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/
安装完成!

4、配置一下参数

在oracle用户的.bash_profile文件中增加2行

[root@oral rlwrap-0.37]# vi /home/oracle/.bash_profile

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'


保存即可,赶快SQL*plus下试试吧~~
本文出自 “飞舞的菜刀” 博客,请务必保留此出处http://caidao.blog.51cto.com/254338/712570
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: