sqlplus backspace – ^H, delete – [[D^, add command history


In sqlplus, pressing backspace writes ^H and delete – [[D^. Your terminal settings affects keyboard behaviour in sqlplus.

Let’s improve our sqlplus – make backspace and delete keys work as expected and in addition to this let’s add a new feature such as maintaining command history.


Install a readline wrapper (rlwrap) – it maintains a separate input history for each command.

[root@rac1 ~]# yum install rlwrap -y 

Create alias for sqlplus in /etc/profile:

alias sqlplus='rlwrap sqlplus' 

Reconnect to the terminal and check that alias is created:

[oracle@rac1 ~]$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias sqlplus='rlwrap sqlplus'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

Connect to sqlplus:

[oracle@rac1 ~]$ sqlplus / as sysdba

And test your new sqlplus 🙂 :

Use backspace, delete, execute some command and then press arrow up to see previous command.

In SQL*Plus, how do I change the prompt to show the connected user and database?

#Connect as oracle user and add the following line at the end of th glogin.sql script.

su - oracle
vi $ORACLE_HOME\sqlplus\admin\glogin.sql
set sqlprompt "_user '@' _connect_identifier > " 

#Now check

sqlplus / as sysdba