zoukankan      html  css  js  c++  java
  • oracle spool生成文件,去掉多余的东西

    在网上找了一种方法:

    [oracle@jumper oracle]$ more sp.sql
    set heading off
    set feedback off
    set term off
    spool a.
    log
    @test.sql
    spool 
    off
    exit
    [oracle@jumper oracle]$ more test.sql
    select username from dba_users;
    [oracle@jumper oracle]$ sqlplus -S "/ as sysdba" @sp
    [oracle@jumper oracle]$ more a.log
    SYS                                                   
    SYSTEM          
    OUTLN           
    SCOTT           
    HAWA            
    CSMIG           
    TEST            
    PERFSTAT        
    MLQIN           
    EYGLE           
    DBSNMP          
    WMSYS           
    [oracle@jumper oracle]

    这种方法用SHELL包装时,如果使用下面这种形式:
    sqlplus -S "/ as sysdba" <<!
    set heading off
    set feedback off
    set term off
    spool a.log
    @test.sql
    spool off
    exit
    !
    其生成的文件还不是纯数据。只有在shell脚本中使用 sqlplus -S "/ as sysdba" @s.sql (s.sql 就是两个!之间的语句。)
    才会生成纯数据。不过这可以使用grep,awk,sed这些工具过滤掉。

  • 相关阅读:
    Linux 添加Nginx 到 service 启动
    PHP编译安装时常见错误解决办法,php编译常见错误
    7 适配器模式
    6 单例模式及其多线程问题
    5 简单工厂、工厂、抽象工厂
    4 装饰者模式
    3 观察者模式
    2 策略模式
    1 UML基础
    代码操作Word时,目录自动更新的两种方法
  • 原文地址:https://www.cnblogs.com/lee/p/604168.html
Copyright © 2011-2022 走看看