DB2 CLI Output Result

When you run queries on the command line in MySQL, you can optionally use " \ G " as the terminator of statements, and instead of the resulting loops displayed horizontally across the screen, it will list each column vertically, with the corresponding data on the right. Is there a way to do the same or similar with the DB2 command line utility?

MySQL regular result example

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

Example MySQL Alternative Result:

 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) 

Obviously, this is much more useful when columns are large rows or when there are many columns in the result set, but this demonstrates formatting better than I can probably explain.

+4
source share
2 answers

I do not think this option is available with the DB2 command line client. See http://www.dbforums.com/showthread.php?t=708079 for some suggestions. For more general information about the DB2 command line client, see the IBM developerWorks DB2 processor and command line scripts article.

+2
source

The DB2 command line utility always displays data in tabular format. that is, rows horizontally and columns vertically. It does not support any other format, such as the terminator \ G for mysql. But yes, you can store ordered columns in DB2 tables by setting DB2_WORKLOAD = ANALYTICS.

 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. 
0
source

Source: https://habr.com/ru/post/1277378/


All Articles