系统集成数据库

DB2如何像Oracle那样在查询时可以用col格式化结果

如:

如果是oracle就可以col TBSPACE format a20

那么在DB2中如何操作呢?

db2 => select tbspace,bufferpoolid from syscat.tablespaces

TBSPACE                                                                                                                          BUFFERPOOLID
-------------------------------------------------------------------------------------------------------------------------------- ------------
SYSCATSPACE                                                                                                                                 1
TEMPSPACE1                                                                                                                                  1
USERSPACE1                                                                                                                                  1
SYSTOOLSPACE                                                                                                                                1
SYSTOOLSTMPSPACE                                                                                                                            1
USERSPACE3                                                                                                                                  1
TEMP                                                                                                                                        1
USER_TEMP                                                                                                                                   1
TBS                                                                                                                                         2
上面这些显示很乱,有什么办法可以格式整齐一点,如下面这样的情况:
http://www.116gouwu.com
SELECT TBSPACE, BUFFERPOOLID FROM SYSCAT.TABLESPACES
TBSPACE               BUFFERPOOLID
------------------         ------------
SYSCATSPACE                   1
TEMPSPACE1                    1
USERSPACE1                    1  

3 record(s) selected.


参与5

4同行回答

FelixFelix数据仓库工程师亚信联创科技(北京)有限公司
db2 "select cast(tbspace as char(25)),cast(bufferpoolid as char(4)) from syscat.tablespaces", then  ...daolin2005 发表于 2010-10-28 17:05 这应该是目前最好的办法了,呵呵。显示全部
db2 "select cast(tbspace as char(25)),cast(bufferpoolid as char(4)) from syscat.tablespaces"
, then  ...
daolin2005 发表于 2010-10-28 17:05

这应该是目前最好的办法了,呵呵。收起
软件开发 · 2010-10-28
浏览906
daolin2005daolin2005数据库管理员某城商行
Make sure the Number you casted is bigger than the longest record in this column. otherwise, the Record will be truncated.显示全部
Make sure the Number you casted is bigger than the longest record in this column. otherwise,
the Record will be truncated.收起
软件开发 · 2010-10-28
浏览855
daolin2005daolin2005数据库管理员某城商行
db2 "select cast(tbspace as char(25)),cast(bufferpoolid as char(4)) from syscat.tablespaces", then it will be print out as short.显示全部
db2 "select cast(tbspace as char(25)),cast(bufferpoolid as char(4)) from syscat.tablespaces"
, then it will be print out as short.收起
软件开发 · 2010-10-28
浏览840
fengshfengsh系统工程师电信行业
可以使用str函数显示全部
可以使用str函数收起
系统集成 · 2010-10-28
浏览1091

提问者

mfkqwyc86
技术经理风哥
擅长领域: 中间件服务器存储

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2010-10-28
  • 关注会员:1 人
  • 问题浏览:7580
  • 最近回答:2010-10-28
  • X社区推广