zoukankan      html  css  js  c++  java
  • sqlplus乱码

    使用SecureCRT或是pietty_ch连接到一台安装有Oracle DB 10g的RHEL4.2的机器,linux使用的shell是默认的bash。 

      在bash提示符下,使用Del键或者Backspace键都能删除光标左右的字符,但是一旦进入sqlplus之后,只能使用Del键来删除光标左 侧的字符,使用Backspace键则显示^H,使用ctrl+H也能删除字符。如果要在sqlplus下仅仅使用Backspace来删除字符,那么有 两种方法:

      第一种是使用stty命令重新定义^H,可以在使用sqlplus之前执行stty erase ^H,也可以把这一句放到Linux用户的.bash_profile文件中。修改后必须执行 . .bash_profile使用命令生效。

      第二种是使用SecureCRT的设置,在会话属性的Terminal->Emulation->Mapped Keys中,选中Backspace sends delete或Delete sends backspace中的任何一个,并确保另一个不被选中。

      此二种方法即可解决backspace出现乱码问题。 

       另一个问题是bash下的sqlplus中使用上下箭头无法显示上一个和下一个命令,而只是显示^[[A。为便于复制可以在SecureCRT中进行设 置,在Global Options->Terminal的Mouse部分,选中Copy on select,并设置Paste on middle(right) button。

    但是这样依然只能显示最近的一条命令,而不能显示更多的历史命令。在Linux下如果需要实现上下翻阅命令的话需要安装其他的工具,rlwrap就是一个。


      rlwrap 的安装使用[SQL中上下键使用 

      今天在论坛上看到了rlwrap工具,感觉很好,我把总结发一下。 

      在 Windows操作系统上,当在DOS命令窗口中运行SQL*Plus的时候,可以使用向上,向下键来跳回之前已经执行过的SQL语句.你可以根据需要修 改他们,然后按Enter键重新提交执行. 然而,当在Linux Shell中运行SQL*Plus的时候,并不提供浏览历史命令行的功能. 为了在Linux中达到同样的目的,你可以安装rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功 能.The rlwrap program is under the GPL license.

      一:安装readline 

      OS的安装光盘里提供了readline包(在安装包的centos/rpms目录下,有两个以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: 

      -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/ 

      [root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile(该文件 

      在你所安装的oracle目录下可找到。 

      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 2008 

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

      Connected to: 

      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> 

      Notes: 

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

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

      添加stty erase ^h

  • 相关阅读:
    偏态分布的均值与中位数关系
    Leetcode 769. Max Chunks To Make Sorted
    【STL】max_element()函数
    [LeetCode] 1338. Reduce Array Size to The Half
    [LeetCode] 985. Sum of Even Numbers After Queries
    [LeetCode] 984. String Without AAA or BBB
    [LeetCode] 1405. Longest Happy String
    [LeetCode] 1646. Get Maximum in Generated Array
    [LeetCode] 926. Flip String to Monotone Increasing
    [LeetCode] 1658. Minimum Operations to Reduce X to Zero
  • 原文地址:https://www.cnblogs.com/ruiy/p/messy.html
Copyright © 2011-2022 走看看