1. rlwrap 的安装使用(已经在linux5企业版上验证)
在Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重新提交执行. 然而,当在Linux Shell中运行SQL*Plus的时候,并不提供浏览历史命令行的功能. 为了在Linux中达到同样的目的,你可以安装rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能.The rlwrap program is under the GPL license.
一:安装readline
oOS的安装光盘里提供了readline包. 或者:URL: http://tianya23.blog.51cto.com/attachment/200912/1081650_1261836999.zip
【注意】以下的安装操作必须在root权限下执行
[root@oracle11g ~]# rpm -ivh readline*
error: Failed dependencies: libtermcap-devel is needed by readline-devel-5.1-1.1.i386.rpm
[root@oracle11g ~]# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm
[root@oracle11g ~]# rpm -ivh readline*
package readline-5.1-1.1 is already installed
[root@oracle11g ~]# rpm -ivh readline-devel-5.1-1.1.i386.rpm
[root@oracle11g ~]# rpm -ivh readline*
error: Failed dependencies: libtermcap-devel is needed by readline-devel-5.1-1.1.i386.rpm
[root@oracle11g ~]# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm
[root@oracle11g ~]# rpm -ivh readline*
package readline-5.1-1.1 is already installed
[root@oracle11g ~]# rpm -ivh readline-devel-5.1-1.1.i386.rpm
如果出现以下问题,表示已经安装了
readline相关的软件包,继续以后的安装即可。
[Intranet root@qa13620 /home/oracle/software]
#rpm -ivh readline-*
warning: readline-5.1-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
file /usr/lib/libhistory.so.5.1 from install of readline-5.1-3.el5.i386 conflicts with file from package readline-5.1-1.1.i386
file /usr/lib/libreadline.so.5.1 from install of readline-5.1-3.el5.i386 conflicts with file from package readline-5.1-1.1.i386
#rpm -ivh readline-*
warning: readline-5.1-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
file /usr/lib/libhistory.so.5.1 from install of readline-5.1-3.el5.i386 conflicts with file from package readline-5.1-1.1.i386
file /usr/lib/libreadline.so.5.1 from install of readline-5.1-3.el5.i386 conflicts with file from package readline-5.1-1.1.i386
二:安装rlwrap
URL: http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.34.tar.gz
[root@oracle11g ~]# tar -zxvf rlwrap-0.30.tar.gz
[root@oracle11g ~]# cd rlwrap-0.30
[root@oracle11g rlwrap-0.30]# ./configure
[root@oracle11g rlwrap-0.30]# make
[root@oracle11g rlwrap-0.30]# make install
[root@oracle11g rlwrap-0.30]# rlwrap
Usage: rlwrap [options] command ...
[root@oracle11g ~]# cd rlwrap-0.30
[root@oracle11g rlwrap-0.30]# ./configure
[root@oracle11g rlwrap-0.30]# make
[root@oracle11g rlwrap-0.30]# make install
[root@oracle11g rlwrap-0.30]# rlwrap
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b <chars> --break-chars=<chars>
-c --complete-filenames
-C <name|N> --command-name=<name|N>
-D <0|1|2> --history-no-dupes=<0|1|2>
-f <completion list> --file=<completion list>
-F <format string> --history-format=<format string>
-h --help
-H <file> --history-filename=<file>
-i --case-insensitive
-l <file> --logfile=<file>
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P <input> --pre-given=<input>
-q <chars> --quote-characters=<chars>
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s <N> --histsize=<N> (negative: readonly)
-t <name> --set-term-name=<name>
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b <chars> --break-chars=<chars>
-c --complete-filenames
-C <name|N> --command-name=<name|N>
-D <0|1|2> --history-no-dupes=<0|1|2>
-f <completion list> --file=<completion list>
-F <format string> --history-format=<format string>
-h --help
-H <file> --history-filename=<file>
-i --case-insensitive
-l <file> --logfile=<file>
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P <input> --pre-given=<input>
-q <chars> --quote-characters=<chars>
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s <N> --histsize=<N> (negative: readonly)
-t <name> --set-term-name=<name>
bug reports, suggestions, updates:
http://utopia.knoware.nl/~hlub/uck/rlwrap/
http://utopia.knoware.nl/~hlub/uck/rlwrap/
【注意】如果出现rlwrap: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory
解决方案:
然后装一个rlwrap解决上下键的问题,
可是运行后,老是出现
rlwrap: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory
找了一大帮资料,最后终于搞定
解决方法:
把libreadline.so.5所在lib位置加入到 /etc/ld.so.conf文件当中
把libreadline.so.5所在lib位置加入到 /etc/ld.so.conf文件当中
只要在/etc/ld.so.conf中加入/usr/local/lib这一行,
一般都可以解決此问题,不仅仅是对于libreadline.so.5,大部
分的so都存在这/usr/local/lib这个目录里面。即:
[root@136_20 /home/oracle/software/rlwrap-0.34]
#cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
#cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
最后将/etc/ld.so.conf保存后,还要执行ldconfig 才会使更改生效
添加到profile文件中: vi /u01/oracle/.bash_profile
添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias rman='rlwrap rman'
三:使用rlwrap
使用向上键调回最后执行的命令,按Enter键重新执行或修改后按Enter键执行.
解决在sqlplus下输错命令后正常删除的方法
添加到profile文件中: vi /u01/oracle/.bash_profile
添加
stty erase ^h
2. ‘l’列出上一条刚执行的sql,‘/’执行上一条sql
3. 用exp到处数据,imp导入数据.
导出:exp 用户名/密码@数据库名字, 需要注意版本的问题,高版本的plsql不能兼容低版本的server,现只能采取本地导出的方法解决。(其中数据库名字需要在tnsnames.ora下面配置)
导入: imp 用户名/密码@数据库名字, 不存在版本问题
本文转自 tianya23 51CTO博客,原文链接:http://blog.51cto.com/tianya23/240631,如需转载请自行联系原作者