Postgresql SQL output set column width


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


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

earth man2Commented:
that's not so difficult just need to use some string functions to do the substring operation

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 ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
earth man2Commented:
Anything we can help you with ?
mikeysmailbox1Author Commented:
Worked great
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.