Postgresql SQL output set column width

Hi

I have some SQL that when it outputs to a file I need to have it set the column to a shorter width.


select app, note, message from abc


output is currently

app                         note                                     message
-----------------------    -----------------------------         ------------------------------------
aaksssjjdjddjdjd    dsssss sssssd ddddd        my message is this long



But needs to be

app                note               message
--------             ------------         ---------------
aakss             dsssss s         my messa


Not sure there is a way to limit the column width on output from psql


Thanks

Mike
LVL 1
mikeysmailbox1Asked:
Who is Participating?
 
earth man2Commented:
that's not so difficult just need to use some string functions to do the substring operation
see http://www.postgresql.org/docs/9.3/static/functions-string.html

select substr(app,1,5) as app, substr(note,1,8) as note, substr(message,1,8 ) as message from abc ;

or using sql standard form

select substring(app for 5) as app, substring(note for 8) as note, substring(message for 8 ) as message from abc ;
0
 
earth man2Commented:
Anything we can help you with ?
0
 
mikeysmailbox1Author Commented:
Worked great
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.