Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB2 CLI result output

Tags:

db2

When running command-line queries in MySQL you can optionally use '\G' as a statement terminator, and instead of the result set columns being listed horizontally across the screen, it will list each column vertically, which the corresponding data to the right. Is there a way to the same or a similar thing with the DB2 command line utility?

Example regular MySQL result

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

Example Alternate MySQL 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 the columns are large strings, or when there are many columns in a result set, but this demonstrates the formatting better than I can probably explain it.

like image 992
dmercer Avatar asked Nov 25 '22 22:11

dmercer


1 Answers

I don't think such an option is available with the DB2 command line client. See http://www.dbforums.com/showthread.php?t=708079 for some suggestions. For a more general set of information about the DB2 command line client you might check out the IBM DeveloperWorks article DB2's Command Line Processor and Scripting.

like image 163
Jay Avatar answered Nov 28 '22 10:11

Jay