What's the deal with column widths and SELECT statements?

droach

ADSM.ORG Senior Member
Joined
Jan 7, 2008
Messages
239
Reaction score
13
Points
0
Location
Cut and Shoot, Texas
When doing SELECT statements from DSMADMC I usually truncate the fields if the results won't display in tabular format. Take FILESPACE_NAME for instance. Because of the length of this field, anytime you have that in a SELECT statement you won't get tabular format unless you truncate it.

So I use either CHAR or SUBST in the SELECT statement to truncate...something like this:
select substr(Filespace_name,1,20) as "12345678901234567890" , filespace_ID from filespaces

It puts out this as a result:
2019-03-14_130335.png

So my question is how can I prevent DSMADMC from adding all this additional width to the Filespace_Name column? I have truncated the field to 20 characters and have my column heading is also at 20 characters. In this case DSMADMC has added 21 additional characters to the column heading width, but my filespace name is still truncated at 20. Anyone know how to prevent this?
 
I don't think you have the option of limiting the width unless you define it within the select statement.

By default, the output follows the character space limits allocated for that column.
 
When doing SELECT statements from DSMADMC I usually truncate the fields if the results won't display in tabular format. Take FILESPACE_NAME for instance. Because of the length of this field, anytime you have that in a SELECT statement you won't get tabular format unless you truncate it.

So I use either CHAR or SUBST in the SELECT statement to truncate...something like this:
select substr(Filespace_name,1,20) as "12345678901234567890" , filespace_ID from filespaces

It puts out this as a result:
View attachment 1531

So my question is how can I prevent DSMADMC from adding all this additional width to the Filespace_Name column? I have truncated the field to 20 characters and have my column heading is also at 20 characters. In this case DSMADMC has added 21 additional characters to the column heading width, but my filespace name is still truncated at 20. Anyone know how to prevent this?


try select cast(filespace_name as char(20))

it does the trick for me
 
Using cast does not work for me. Does the same thing as cast and substr.

select cast(Filespace_name as char(20)), filespace_ID, cast(cap......
SQL:
Unnamed                                     FILESPACE_ID         Size_MB
----------------------------------------    -------------     -----------
/var/lib/docker/devi                                 1720            0.07
/var/lib/docker/devi                                 1719            0.04
/var/lib/docker/devi                                 1718            0.45
/var/lib/docker/devi                                 1717            3.09
/var/lib/docker/devi                                 1716            3.09

Edited by @marclant to properly display output.
 
Last edited by a moderator:
Back
Top