2008-10-01 59 views
4

在MySQL中运行命令行查询时,您可以选择使用'\ G'作为语句终止符,而不是在屏幕上水平列出结果集库,而是将每列垂直列出,将相应的数据提供给右侧。有没有与DB2命令行实用程序相同或相似的方法?DB2 CLI结果输出

例普通的MySQL结果

mysql> select * from tagmap limit 2; 
+----+---------+--------+ 
| id | blog_id | tag_id | 
+----+---------+--------+ 
| 16 |  8 |  1 | 
| 17 |  8 |  4 | 
+----+---------+--------+ 

实例替代的MySQL结果:

mysql> select * from tagmap limit 2\G 
*************************** 1. row *************************** 
    id: 16 
blog_id: 8 
tag_id: 1 
*************************** 2. row *************************** 
    id: 17 
blog_id: 8 
tag_id: 4 
2 rows in set (0.00 sec) 

显然,这是更为有用,当列是大型字符串,或者当有一个结果的列设置,但这表明格式比我可以解释它更好。

回答

0

DB2命令行实用程序总是以表格格式显示数据。即水平行和垂直行。它不支持任何其他格式,如用于mysql的\ G语句终结符。但是,是的,当设置DB2_WORKLOAD = ANALYTICS时,可以将列组织的数据存储在DB2表中。

db2 => connect to coldb 

    Database Connection Information 

Database server  = DB2/LINUXX8664 10.5.5 
SQL authorization ID = BIMALJHA 
Local database alias = COLDB 

db2 => create table testtable (c1 int, c2 varchar(10)) organize by column 
DB20000I The SQL command completed successfully. 
db2 => insert into testtable values (2, 'bimal'),(3, 'kumar') 
DB20000I The SQL command completed successfully. 
db2 => select * from testtable 

C1   C2   
----------- ---------- 
      2 bimal  
      3 kumar  

    2 record(s) selected. 

db2 => terminate 
DB20000I The TERMINATE command completed successfully.