Sunday, October 08, 2006

How to use rlwrap to get a command history in sql*plus

sql*plus does not have a command history function under Linux and Unix.
Lately I listened to Tom Kyte at one of his seminars he delivered in September in Zurich. He used a virtual Linux machine and had a command history for his sql*plus obviousely.
He told us that he used a utility called rlwrap for this.

rlwrap is a readline wrapper for shell commands which uses input from the controlling terminal.
It adds a persistent input history for each command and supports user-defined completion.

I simply had to get it!
And I think that this is worth sharing it.
Here is how it works and how you can get it too.

You can download the sources for the rpm for rlwrap from
. The most recent version I could find is version 0.26.
There you also find a README and the manpage for rlwrap.

After downloading and unpacking the tar.gz I ran as root (#)
make check
make install

and that was it.

Now I could call sqlplus this way:
$ rlwrap sqlplus user/password@sid.

Finally I create an alias
alias sqlp ="rlwrap sqlplus"
(pls see Laurent Schneider's comment on this post about alias sqlplus!)
Now I can simply call sqlplus as I always have done
and have a commend history with the and keys on my keyboard.

This will put an end to the stoneage habits we have all got used to too much!


At Mon Oct 09, 09:47:00 AM, Blogger Laurent Schneider said...

alias sqlplus="rlwrap sqlplus"

this I would avoid. rlwrap does not support non-interactive mode (echo xxx | sqlplus), is not an oracle support tool, and crashes occasionnaly.

Personnaly I do
alias q="rlwrap sqlplus"
so that I can always use sqlplus to run important script, and keep rlwrap for not-productive stuff.


At Mon Oct 09, 10:16:00 AM, Blogger HP Fuchs said...

I don't believe it! This morning I tried to remember the name of a tool I once saw somebody using at an Oracle University class.
Ten minutes later, when I was browsing through google reader I saw this post on your blog :-))

At Mon Oct 09, 12:24:00 PM, Blogger lutz_hartmann said...

Hi Laurent,
cool! Thanks for pointing this out!

At Mon Oct 09, 12:27:00 PM, Blogger lutz_hartmann said...

there must be some kind of interconnect between us, what do you say?

It's chool män!


Post a Comment

<< Home