Fixing the Backspace key in SQL*Plus on Linux
Fix the ^H output of the Backspace key in SQL*Plus, using stty erase or rlwrap.
In a Linux terminal, the Backspace key may print ^H instead of deleting the character when you use SQL*Plus. Two fixes are possible: set the erase key of the terminal, or wrap sqlplus with rlwrap, which also adds line editing and command history.
Set the erase key in the terminal
- Type
stty eraseand a space. - Press Ctrl+V, then press the Backspace key. The terminal shows
^H. - Press Enter.
The command line now reads:
stty erase ^H
To keep the setting, add the same line to your shell profile.
Install rlwrap
Install the readline development package first. The original note uses a wildcard that matches several packages:
yum install readline*
To build rlwrap from source, download the release and install it:
curl -L https://github.com/hanslub42/rlwrap/releases/download/v0.45.2/rlwrap-0.45.2.tar.gz -o rlwrap.tar.gz
tar -xzf rlwrap.tar.gz
cd rlwrap-0.45.2
./configure
make
make check
sudo make install
Create aliases
Add these lines to the .bash_profile of the Oracle software owner, then reload the profile:
alias rlsqlplus='rlwrap sqlplus'
alias rlrman='rlwrap rman'
Notes
- The aliases use the names
rlsqlplusandrlrman. The originalsqlplusandrmancommands are unchanged. - The Backspace fix is based on the answer in the Stack Overflow thread on Backspace in sqlplus.