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).

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.

3
  • 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. 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? 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.