zoukankan      html  css  js  c++  java
  • 【Oracle sqlplus】指定结果集的列宽度 使用命令"column 列名 format a列宽"

    SqlPlus有时会出现非预期的折行,比如这样:

    SQL> select id,level,lpad(' ',(level-1)*3)||name as name
      2      from emp3
      3      start with mngid is NULL
      4      connect by mngid=prior id;
    
            ID      LEVEL
    ---------- ----------
    NAME
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
             1          1
    Andy
    
             2          2
       Bill
    
             4          3
          Douglas
    
    
            ID      LEVEL
    ---------- ----------
    NAME
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
             5          3
          Edin
    
             3          2
       Cindy
    
             6          3
          Felix
    
    
            ID      LEVEL
    ---------- ----------
    NAME
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    简直不能忍,好在有 “column name format a40”命令的帮忙。

    这一句的意思是指定name列的宽度是40个字符。

    再弄就好了。

    SQL> column name format a40;
    SQL> select id,level,lpad(' ',(level-1)*3)||name as name
      2      from emp3
      3      start with mngid is NULL
      4      connect by mngid=prior id;
    
            ID      LEVEL NAME
    ---------- ---------- ----------------------------------------
             1          1 Andy
             2          2    Bill
             4          3       Douglas
             5          3       Edin
             3          2    Cindy
             6          3       Felix
             8          4          Hitler
            10          5             Jeep
             9          4          Idiot
            11          5             King
            12          6                Linconn
    
            ID      LEVEL NAME
    ---------- ---------- ----------------------------------------
             7          3       Green
    
    已选择12行。

    当然,除了 ”column 列名 format a宽度“ 命令,SqlPlus还提供了如”set linesize 宽度“之类的命令,大家可以试试效果。

    参考资料:

    https://blog.51cto.com/meiling/1775065

    END

  • 相关阅读:
    linux软件安装
    shell脚本
    ssh密钥登录及远程执行命令
    shell编程
    vi编辑器
    linux入门
    《玩转Bootstrap(JS插件篇)》笔记
    SharePoint BI
    Apache-ActiveMQ transport XmlMessage
    C#操作AD及Exchange Server总结(二)
  • 原文地址:https://www.cnblogs.com/heyang78/p/15190028.html
Copyright © 2011-2022 走看看