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这些工具过滤掉。

  • 相关阅读:
    E. Arranging The Sheep
    B. Box Fitting
    E. Permutation by Sum
    D. Corrupted Array
    联通 F677V2 光猫改桥接
    IntelliJ IDEA 常用快捷键整理
    Git 常用命令速查表
    Git 入门操作指南
    Anaconda 常用命令总结
    VS code 快捷键整理
  • 原文地址:https://www.cnblogs.com/lee/p/604168.html
Copyright © 2011-2022 走看看