1

Using DB2 9.7, is it possible to produce a result set where the column-headers contain line-breaks? Something like:

select field_name as "Line1<br>Line2" from table_name

I want the column-header to look like this:

Line1
Line2

However, this is not for HTML. Instead I'm wanting it to look this way when I run the query (raw) in my sql editor (Dbeaver) and in the CSV file I export from Dbeaver (so that the columns are narrower -- to prevent horizontal scrolling while viewing the result-set).

Lonnie Best
  • 133
  • 10

1 Answers1

3

DB2 will allow you to use a new line character in a quoted identifier:

$ db2 'select ibmreqd "foo
> bar" from sysibm.sysdummy1'

foo
bar
-------
Y      

  1 record(s) selected.

The question is, will Dbeaver let you enter a new line character where you want it.

mustaccio
  • 20,465
  • 17
  • 49
  • 60
  • You're right. Your query runs fine, but Dbeaver ignores the new line in the column-headers that are displayed in dbeaver. Fortunately, however, the new line is NOT ignored once I export the result-set from Dbeaver to a cvs file. – Lonnie Best Oct 19 '16 at 19:27
  • Do you know of a way of doing a new line within those quotes without actually doing a line break in the SQL formatting? – Lonnie Best Oct 19 '16 at 19:28
  • 1
    Like I said, that depends on the client entirely. Column aliases are identifiers, so DB2 itself is not going to do any interpretation or interpolation. – mustaccio Oct 19 '16 at 19:34