1 Problem Description
SQLPLUS cannot get history commands using up and down arrows, as shown in the following figure:
Pressing the up and down arrows will display ^[[A/^[[B.
2 Solution
Install rlwrap (rlwrap). If possible, you can use package manager to install rlwrap.
2.1 Download Source Code
Official Github can be found here, and the latest version is 0.43:
2.2 installation
After uploading to the server, decompress and compile the installation:
Tar - ZXVF rlwrap - 0.43. Tar. GzcdRlwrap 0.43./configure make make installCopy the code
I encountered the following error in the./configure step:
Install a library to solve:
yum install readline-devel
Copy the code
Again./configure is fine:
2.3 test
Use rlwrap sqlPlus instead of sqlPlus:
rlwrap sqlplus xxx/xxx as sysdba
Copy the code
So you can use the up and down arrows.
Since the author is testing on root, there may be permissions issues when testing on Oracle users, as shown in the following figure:
Create the file in the corresponding directory:
cd /home/oracle
sudo touch .sqlplus_history
Copy the code
Cannot execute after created:
Modify group permissions:
sudo chmod g+w .sqlplus_history
Copy the code
2.4 the alias
An alias can be added for ease of use:
alias sp='rlwrap sqlplus'
Copy the code
So you can use it next time
sp xxx/xxx as sysdba
Copy the code
To log in.