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
here. 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 (#)
./configure
make
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!
October 9, 2006 at 10:23 am |
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.
cheers
laurent
October 9, 2006 at 10:24 am |
Hi Laurent,
cool! Thanks for pointing this out!
=;-)
October 9, 2006 at 10:24 am |
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
October 9, 2006 at 10:27 am |
Hi HPFUCHS,
there must be some kind of interconnect between us, what do you say?
It’s chool män!
=;-)
July 17, 2007 at 1:33 pm |
i saw it also during an oracle 11g event and was very interested. here you can find my article http://bd-home.net/archives/10-Command-history-and-keyword-completion-in-SQLPlus.html and here http://www.linuxification.at/rlwrap_ext.html you find a oracle keyword list including some shell scripts.
July 19, 2007 at 7:55 am |
Hi BD,
this is also very interesting!
Thanks for pointing it out.
Which 11g event were you at anyway?
Thanks,
LUTZ
=;-)
January 2, 2008 at 8:47 pm |
I’ve had pretty much this exact advice in an article on my website since 2005! Tom actually got his first taste of rlwrap as a result of my original article… just thought I’d mention it.
January 13, 2008 at 1:25 pm |
Hi dizwell,
I just wanted to share what I like to use because I think that knowlege is not private property and should be shared.
I did not inquire about the inventor.
I found out that a lot of people use rlwrap
and a lot do not even know about it.
So what is the problem?
=;-)
January 23, 2008 at 9:38 pm |
Hi dizwell,
I just received this from Ausria:
Hi Lutz!
I am that guy who gave that event were user BD heard about rlwrap. I found out about it 18 months ago and use it very often since then. I produced some additional files to use name completion with the tab key.
It is quite nice to have a tool completing names of DBA_ views, parameters and so on. I put those files on my website for download (for free, of course). The link to the english web page is:
http://www.linuxification.at/rlwrap_ext.html.en
have fun
August 21, 2008 at 10:28 pm |
Thanks a lot for sharing this invaluable info. Finally sqlplus can be more friendly
September 15, 2008 at 3:06 pm |
Thanks a lot for this. I needed precisely this in my shellscripts. Like:
“rlwrap cat >> filename”
September 15, 2008 at 8:17 pm |
How can we prevent passwords from ending up in the .sqlplus_history file?
I tried this but the password still goes into history:
rlwrap -a”Enter Password:” sqlplus /nolog
October 3, 2008 at 7:58 am |
On HP-UX, one can call sql*plus from ied
ied sqlplus sunil/bhola@DB1
October 9, 2009 at 2:30 am |
I got this interesting links from my friend. Really nice blog In my opinion making ebook about it and selling it is a really nice idea. Check my site out about at