Tag Archives: sqlplus

SQLPlus Command Line History

Wow, I can’t believe I’ve not considered this before! SQLPlus is a great tool, I use it all the time as it’s great for doing little bits and pieces where you don’t need the tools in SQL Developer (which is my preferred client for most big stuff) or you don’t want to go to the trouble of starting up a GUI. My major gripe with it has always been it’s almost complete lack of a command line history feature which is astounding considering how long that kind of feature has been available for other shells (bash, psql, mysql, even the Windows Command Prompt since XP).
Anyway there is a workaround to ‘add’ the feature! You’ll need to install the ‘rlwrap’ package which is a

…wrapper that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is kept between invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line.

You can get that from Sourceforge or in my case I found it in the Ubuntu Universe repository (there’s rpm’s on Sourceforge) so I just did:

$ sudo apt-get install rlwrap

You can call SQLPlus from rlwrap like this:

$ rlwrap sqlplus user@database

or to make things simpler use alias:

$ alias sqlplus='rlwrap sqlplus'

all done.