欢迎光临
我们一直在努力

SQLPlus命令使用指南(二)-数据库专栏,ORACLE

建站超值云服务器,限时71元/月

/*————————————————————————————

/*欢迎转载,请保留这部分信息

/*翁彦      2004-1-15

/*————————————————————————————

五 报表制作命令

报表制作命令是最重要的sql*plus命令,也是dba经常用到的。下面,就让我简单地说明一下。

(1)    ttitle命令

放置一个报表的标题。

语法:

ttitle

——

 

places and formats a title at the top of each report page.

enter ttitle with no clause to list its current definition.

 

the old form of ttitle is used if only a single word or

a string in quotes follows the ttitle command.

 

tti[tle] [printspec [text|variable] …] | [on|off]

 

where printspec is one or more of the following clauses:

 

    col n          le[ft]        bold

    s[kip] [n]     ce[nter]      format text

tab n          r[ight]

主要参数的说明:

¨         报表标题的显示的位置,有left,center决定

¨         还可以使用用户的变量(内容有系统来维护),如sql.pno页号, sql.lno行号等等

¨         col[n] 就是在第几个字符位置开始显示标题。

 

(2)    column命令

这个命令主要用途,是规范查询的结果的输出格式。输出格式包括了数字也可以指定显示的宽度。column设置后,一直保持有效。除非,你重新使用column设置该列或者用column <column name> clear。

语法:

column

——

 

specifies display attributes for a given column, such as:

    – column heading text

    – column heading alignment

    – number data format

    – column data wrapping

 

also lists the current display attributes for a single column

or all columns.

 

col[umn] [{column | expr} [option…] ]

 

where option is one of the following clauses:

    ali[as] alias

    cle[ar]

    entmap {on|off}

    fold_a[fter]

    fold_b[efore]

    for[mat] format

    hea[ding] text

    jus[tify] {l[eft] | c[enter] | c[entre] | r[ight]}

    like {expr | alias}

    newl[ine]

    new_v[alue] variable

    nopri[nt] | pri[nt]

    nul[l] text

    old_v[alue] variable

    on|off

wra[pped] | wor[d_wrapped] | tru[ncated]

 

下面就举例说明:

sql> column sal alias salary format $99,990.90

我们指定了sal这个列的一个别名和数字的money显示格式,下面的显示结果显示了设置后的效果。

图1

关于format的提示:

¨         文字各式的设置,用a[n]来表示,n表示显示的长度。那么这个文字列的显示长度就按照n个字符的宽度,如果内容>n,就会自动转行。如图2

¨         日期格式,sqlplus缺省显示的日期格式按照nls_lang设置来显示。缺省是a9。那么,你可以通过设置数据库启动参数,或者sqlplus的环境变量,或者用alter session命令来规范日期的显示;也可以通过to_char来转换显示内容;也可以用column命令来指定显示长度。

¨         数字格式,说明一些常用的符号。如图3

9             代表一个数字字符

0                           在指定的位置显示前导0或后置0

$             美元货币符号

b             显示一个空,如果是0的话

mi            显示负号,如果小于0的话

,                     显示千分位分隔符

.                     显示小数点

g             和,一样,显示千分位分组符号

l              显示本地区域的货币符号

图2

 

图 3

关于其他参数的提示

justify主要规定了列显示内容的对齐方式。left ,right,center。

like指定该列的显示参照某个其他列的显示方法。如:column comm like sal

new line 换行显示这个列的内容

null text  如果是null,显示一个字符串,相当于isnull函数。

 

未完待续。。。。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » SQLPlus命令使用指南(二)-数据库专栏,ORACLE
分享到: 更多 (0)

相关推荐

  • 暂无文章