As you know, SQL * Plus in the command line of Windows has the command line history callback function. Under SQL * Plus, you can use the "Up and down" arrow keys on the keyboard to call back the command line. this function is not available in Linux (although shell can do this, SQL * Plus cannot ). this feature is almost indispensable for CLI fans. I don't know why Oracle didn't add this feature. unknown.
Some SQL * Plus alternative products (such as gqlplus and yasql) have the command-line editing and command history functions, but these products are developed slowly-some have even stopped updating.
(See SQL * Plus Replacement Tools such as gqlplus-http://sourceforge.net/projects/gqlplus and yasql-http://sourceforge.net/projects/yasql ).
While hanging out on the network, I found a solution under Linux.
The tool is called uniread-http://sourceforge.net/projects/uniread/), a friend who is familiar with Linux may see that this name has come up with something: Readline. good. This tool uses the GNU Readline library to meet our needs.
Let's take a look at the introduction of this tool:
Uniread-universal Readline
-Adds full Readline support (command editing, history, etc .) to any existing interactive command-line program. common examples are Oracle's sqlplus or Jython. uniread will work on any POSIX platform with Perl.
It can be seen that this tool can provide complete Readline support for any existing interactive command line program.
Download the source program from this site. The current stable version is 1.01.
Before installing the tool, the system must install Perl and three Toolkit:
GNU Readline
Http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
Term: Readline: GNU
Http://search.cpan.org/dist/Term-ReadLine-Gnu/
IO: tty
Http://search.cpan.org/dist/IO-Tty/
The page above GNU Readline cannot be opened on my machine (not accessible ?), If you do the same, you can go to the http://www.gnu.org/directory/readline.html page to download.
After the download, decompress the package:
# Tar-xzvf readline-4.3.tar.gz
Go to the directory to compile and install:
#./Configure
# Make
# Make install
Install tar-zxvf... in the following two directories:
# Perl makefile. pl
# Make
# Make install
After installation is complete, install uniread:
# Tar-xzvf uniread-1.01.tar.gz
# Cd uniread-1.01
#./Configure
# Make
# Make install
Note: the absolute path of the above command line operations is omitted for convenience. Your environment will definitely be different from mine. In addition, we recommend that you compile it with a common user and then use root to make install.
After the installation is complete, switch to the Oracle user:
$ Uniread sqlplus/nolog
The output is similar to the following:
[Uniread] loaded history (12 lines) // I have run it once, and uniread buffered 12 lines of History
SQL * Plus: Release 10.1.0.2.0-production on Sat Mar 6 00:23:05 2004
Copyright (c) 1982,200 4, Oracle. All rights reserved.
SQL>
View the manual of uniread:
$ Man uniread
You can create a sqlplus alias. The usage of uniread is transparent. Is it very convenient? Don't forget: this tool is universal, not only SQL * Plus, but other similar command line programs.
FAQ
To delete the command line history, you can simply use the following operations:
[Oracle @ Foo Oracle] $ echo ''>. uniread/sqlplus
[Oracle @ Foo Oracle] $
[Oracle @ Foo Oracle] $ LS-LTR. uniread/
Total 4
-RW ------- 1 Oracle 1 Oct 31 sqlplus
[Oracle @ Foo Oracle] $
[Oracle @ Foo Oracle] $ uniread sqlplus
[Uniread] loaded history (1 lines)
SQL * Plus: Release 9.2.0.4.0-production on Sun Oct 31 15:58:29 2004
This article from: http://oracle.chinaitlab.com/PLSQL/38591.html