How to enables command-line history in SQL*PLUS
SQL*PLUS (sqlplus) does not let you press ↑ “up” or ↓ “down” to browse previous commands. You can inspect only one previous command. This can be inconvenient because earlier commands must be typed again.
On Linux, rlwrap intercepts user input to SQL*PLUS and saves it in a history so that users can browse earlier commands using ↑ “up” or ↓ “down”.
Installing and using rlwrap with SQL*PLUS
-
Install EPEL repo****CentOS 5
rpm -ivh http://mirror1.ku.ac.th/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpmCentOS 6rpm -ivh http://mirror1.ku.ac.th/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm -
Install rlwrap
yum install rlwrap -
Edit the oracle user’s bash_profile so that rlwrap is used every time.
su - oracle vi .bash_profileAdd the following command.
alias sqlplus='/usr/bin/rlwrap sqlplus' alias rman='/usr/bin/rlwrap rman'
When using sqlplus, you can now press ↑ “up” or ↓ “down” to browse previous commands, or “Crtl + r” to search the history faster (as in Bash).