sqlplus执行脚本 乱码_安装readline和rlwrap解决sqlplus乱码

在Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修改他们,然后按Enter键重新提交执行.

然而,当在Linux Shell中运行SQL*Plus的时候,并不提供浏览历史命令行的功能.

为了在Linux中达到同样的目的,你可以安装rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能.The rlwrap program is under the GPL license.

一:安装readline   www.2cto.com

OS的安装光盘里提供了readline包.

[root@oracle11g ~]# rpm -Uvh readline*

error: Failed dependencies: libtermcap-devel is needed by readline-devel-5.1-1.1.i386.rpm

[root@oracle11g ~]# rpm -Uvh libtermcap-devel-2.0.8-46.1.i386.rpm

[root@oracle11g ~]# rpm -Uvh readline*

package readline-5.1-1.1 is already installed

[root@oracle11g ~]# rpm -Uvh readline-devel-5.1-1.1.i386.rpm

二:安装rlwrap

Download:http://utopia.knoware.nl/~hlub/uck/rlwrap/

[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 ...

Options:   www.2cto.com

-a[password:]              --always-readline[=password:]

-A                         --ansi-colour-aware

-b                 --break-chars=

-c                         --complete-filenames

-C                --command-name=

-D <0|1|2>                 --history-no-dupes=<0|1|2>

-f       --file=

-F         --history-format=

-h                         --help

-H                  --history-filename=

-i                         --case-insensitive

-l                  --logfile=

-n                         --no-warnings

-p[ANSI colour spec]       --prompt-colour[=ANSI colour spec]

-P                 --pre-given=

-q                 --quote-characters=

-m[newline substitute]     --multi-line[=newline substitute]

-r                         --remember

-v                         --version

-s                     --histsize= (negative: readonly)

-t                  --set-term-name=

bug reports, suggestions, updates:

http://utopia.knoware.nl/~hlub/uck/rlwrap/

[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile

添加

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

三:使用rlwrap

[oracle@oracle11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Jul 29 21:28:30

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to:   www.2cto.com

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$sga;

NAME                      VALUE

-------------------- ----------

Fixed Size              1299116

Variable Size         155192660

Database Buffers       79691776

Redo Buffers            2347008

使用向上键调回最后执行的命令,按Enter键重新执行或修改后按Enter键执行.

SQL> select * from v$sga;

NAME                      VALUE

-------------------- ----------

Fixed Size              1299116

Variable Size         155192660

Database Buffers       79691776

Redo Buffers            2347008

SQL>   www.2cto.com

Note:

解决在sqlplus下输错命令后正常删除的方法

[oracle@oracle11g ~]$ vi /home/oracle/.bash_profile

添加

stty erase ^h

作者 aaron8219

小编推荐:欲学习电脑技术、系统维护、网络管理、编程开发和安全攻防等高端IT技术,请 点击这里注册账号,公开课频道价值万元IT培训教程免费学,让您少走弯路、事半功倍,好工作升职加薪!

免责声明:本站系公益性非盈利IT技术普及网,本文由投稿者转载自互联网的公开文章,文末均已注明出处,其内容和图片版权归原网站或作者所有,文中所述不代表本站观点,若有无意侵权或转载不当之处请从网站右下角联系我们处理,谢谢合作!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值