利用uniread 解決 Linux下的SQL*Plus 命令列曆史回調功能
最後更新:2017-02-28
來源:互聯網
上載者:User
解決|命令列
利用uniread 解決 Linux下的SQL*Plus 命令列曆史回調功能
作者: Fenng
大家知道, 在 Windows 平台 命令列中的 SQL*Plus 有命令列曆史回調的功能,在SQL*Plus工具下面,可以利用鍵盤的
"向上向下"方向鍵對命令列的進行回調.而在Linux上則沒有該功能(雖然 Shell 可以做到這一點,但是 SQL*Plus 不可以).
而該功能對於CLI愛好者來說幾乎是不可缺的,不知道為什麼 Oracle 不把這個功能加進來.不得而知了.
一些SQL*Plus 的替代產品(如 gqlplus 以及yasql)具備command-line editing 和Command history的功能, 但是這
些產品的開發進度較慢--有的甚至已經停止了更新.
(參見: gqlplus http://sourceforge.net/projects/gqlplus 以及 yasql http://sourceforge.net/projects/yasql/
等 SQL*Plus 替代工具 ).
在網路上閑逛的時候, 發現了一個在Linux下面的解決辦法, 現在和大家共用.
該工具叫做uniread ( http://sourceforge.net/projects/uniread/ ) ,熟悉Linux下變成的朋友可能看到這個名字已經
想起了一些東西:readline . 不錯,該工具就是利用GNU的readline庫來完成我們的需求的.
我們先看一下對該工具的介紹:
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.
可以看出,該工具可以對任何既有的互動命令列程式都可提供完備的readline支援.
從該網站下載來源程式.目前的穩定版本是1.01.
在安裝該工具之前系統必須安裝好Perl, 此外還必須要三個工具包:
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/
其中GNU readline 上面的網頁在我的機器上打不開(不可訪問?),如果你也是同樣情況,可以到
http://www.gnu.org/directory/readline.html 這個頁面下載.
下載後,首先解壓縮:
# tar -xzvf readline-4.3.tar.gz
進入進入到該目錄中編譯並安裝:
# ./configure
# make
# make install
後面兩個的安裝: tar -zxvf ....
進入到該目錄中:
# perl Makefile.pl
# make
# make install
都安裝完了之後,進行 uniread 的安裝:
#tar -xzvf uniread-1.01.tar.gz
#cd uniread-1.01
#./configure
#make
#make install
注: 以上的命令列操作所在絕對路徑為了方便而省略,你的環境肯定會和我的不同,此外,建議使用普通使用者編譯,然後用 root 進行
make install .
都安裝完了之後
切換到Oracle使用者下:
$ uniread sqlplus /nolog
輸出類似如下:
[uniread] Loaded history (12 lines) //我的已經運行一次了,uniread 緩衝了12行history
SQL*Plus: Release 10.1.0.2.0 - Production on Sat Mar 6 00:23:05 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL>
查看uniread的Manual:
$man uniread
你可以做個sqlplus 的別名 ,uniread的使用是透明的,是不是很方便了? 不要忘了:這個工具是有通用性的,不止是 SQL*Plus
可以這樣用,其他類似的命令列程式也能如此的.
參考內容:
uniread的網站 http://sourceforge.net/projects/uniread
GNU readline http://www.gnu.org/directory/readline.html
"The Readline library provides a set of functions for use by applications that allow users to edit
command lines as they are typed in."
目前還算萬能的Google http://www.google.com
原文出處:
<a href="http://www.dbanotes.net/Oracle/uniread-howto.htm">http://www.dbanotes.net/Oracle/uniread-howto.htm</a>