https://blogs.oracle.com/middleware/entry/getting_history_from_sqlplus_using
Remember previous history commands in SQLPlus on Linux with rlwrap
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
http://download.fedora.redhat.com/pub/epel/5/i386/rlwrap-0.37-1.el5.i386.rpm
rlwrap 64Bit
http://download.fedora.redhat.com/pub/epel/5/x86_64/rlwrap-0.37-1.el5.x86_64.rpm
3. From the staging area install the rlwrap utility, e.g.:
[root@OELTEST ~]# rpm -ivh rlwrap-0.37-1.el5.x86_64.rpm
warning: rlwrap-0.37-1.el5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 217521f6: NOKEY
error: Failed dependencies:
libreadline.so.5()(64bit) is needed by rlwrap-0.37-1.el5.x86_64
libtermcap.so.2()(64bit) is needed by rlwrap-0.37-1.el5.x86_64
[root@OELTEST ~]# yum install compat-readline5
[root@OELTEST ~]# yum install compat-libtermcap
[root@OELTEST ~]# 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
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
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;
No Comments