Wednesday, October 12, 2011

How to get command-line history in SQL*PLUS with rlwrap

sql*plus does not have a command-line history function under Linux and Unix.
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.

You can install it via yum if you have enabled the EPEL repository.
Or you can download the sources from here
Then open a terminal and go to the catalog you downloaded it to

If you have the EPEL repository enabled
Open a terminal
su - root
yum install rlwrap

Otherwise you do like this. Again in the folder you downloaded the file to.
Open a terminal
su - root
tar -zxvf rlwrap-0.37.tar.gz
make install

Now you can call sqlplus like this:
rlwrap sqlplus user/password@sid
I also recommend creating an alias like this
alias sqlp =”rlwrap sqlplus”
Now you can start the wrapped sqlplus with sqlp and have command history with the ↑ and ↓ keys on your keyboard.
Web Analytics