Sie sind auf Seite 1von 2

How to Install rlwrap

Getting History from SQLPlus using Linux

A colleague of mine just asked me how do you get history in SQLPlus on Linux the same way
you get by default in windows, e.g. when you press the up key you see the previous commands
executed. I have never really given it much thought in the past, but there must be a way. After a
quick Google search I found a solution. This blog is really for my future reference as the
examples I found on the net required a bit of thought.

The post assumes you are using RedHat or OEL, It will work for other Linux OS but you will
need to source the right application. I'm installing on OEL 5.7 64 bit.

The key behind this solution is the utility call rlwrap which is a read line wrapper. It maintains a
separate input history which can be edited.

1. Login to you Linux machine as the root user

2. Download the rlwrap utility using the appropriate link below and save it to a staging area
on the Linux machine:
rlwrap 32Bit
rlwrap 64Bit
3. From the staging area install the rlwrap utility, e.g.:

rpm -ivh rlwrap-0.37-1.el5.x86_64.rpm

4. Connect as the oracle user (or the user you connect to SQLPlus)

5. Edit the .bashrc file ($HOME/.bashrc) and add the following line in the aliases
section.

alias sqlplus ="rlwrap sqlplus"

6. Initialize the .bashrc file with the following command

. .bashrc

7. Login to SQLPlus and history should be enabled

sqlplus scott/tiger@orcl

SQL*Plus: Release 11.2.0.2.0 Production on Wed Jan 25


04:07:40 2012

Copyright (c) 1982, 2010, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 -
64bit Production
With the Partitioning, OLAP, Data Mining and Real
Application Testing options

SQL> select count(*) from emp;

COUNT(*)
----------
15

Press the up key

SQL> select count(*) from emp;

Now you are done. Enjoy

Das könnte Ihnen auch gefallen